Actually it's 2 lines. I was looking at post 2 when I wrote 1 line.
Moving
Quote:
strPassword = prompt("Please enter a valid password","");
|
into the while loop will give it a new password to check every loop
Tweaked a little further it will handle the cancel button too:
Quote:
<script language = "JavaScript">
function validatePassword()
{
//Declare and initilise variables
var intIncludesAt = 0; //Changes to 1 if an @ sign is found
var intValidPassword = 0;
var intIncludesAt = 0;
var strPassword = "";
var intFirstChar = 0;
var abort = 0;
while(intValidPassword == 0 && abort == 0)
{
strPassword = prompt("Please enter a valid password","");
if(strPassword != null) // Will be null if cancel button pressed
{
intFirstChar = parseInt(strPassword.charAt(0)); //First character of the password
for (intCount = 0; intCount < strPassword.length; intCount ++)
{
if(strPassword.charAt(intCount) == "@")
{
intIncludesAt = 1;
}
}
if (strPassword.length >= 6 && intIncludesAt == 1 && intFirstChar == 0)
{
intValidPassword = 1;
alert("Your password is valid!")
}
}
else
{
abort = 1;
alert("Password entry aborted")
}
}
}
</script>
|
(For some reason all the indentation has gone

)
And yes to your last question.
Regards,
Jon.