It sometimes say the password is invalid when it is actually valid
<p>I need to make sure it begins with a <code>Z</code>, has 8 minimum characters and has an <code>*</code>.
Consider this function:</p>

<pre><code>function validatePassword()    
{
var strPassword 

//Request user enter their password then check its validity

strPassword = prompt("Please Enter A Valid Password","");

while ((strPassword.length &lt;7) || (strPassword.indexOf('*') ==-1)  || (strPassword.charAt(0) != 'Z')) {
{
alert("Your password is invalid, \n Please try again")
strPassword = prompt("Please Enter A Valid Password","");
}

//Outcome if password is valid

alert("Your password is valid")

//End while

}
}
</code></pre>
