I want to validate password field. I have tried following code, but getting message that “Your password must satisfy the following……………”, even though i enter a correct password format.
var re = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,8}$/;
if ( !re.test(rpassword) )
{
alert('Your password must satisfy the following. \n\n* Password should be 4 to 8 character long. \n* Password should have at least one alphabet. \n* Password should have at least one numeric value. \n* Password should have special characters.');
return false;
}
Not getting what is wrong with this code. Please help !!
Are you sure you don’t want:
?? You say that “rpassword” is a reference to the password element in your form. If so, then you have to get its “value” attribute first.