Forum Moderators: open
I want to validate my password in a signup form using Javascript ..and it should work in such a way that when the user enters a password and moves to the next form field (which is re-enter password), an alert box should come up if validation fails..
The logic that I have come up with is this....
<script type="text/javascript">
function passValid() {
var pass = document.getElementById("password").value;
var passLen = parseInt(pass.length);
if(passLen < 8) {
alert("Your password is too short. Please choose one atleast 8 characters long.";
}
}
</script>
and in the HTML form ...
<input type="password" name="password" id="password" value="" onChange="passValid();"/>
But this is not working..
Or can this be done only when the form is submitted?..
Is there any other event which can be used here?