Password Validation

[Total: 0    Average: 0/5]

This script will ensure that the password entries match.

Head Code:

<script> 
function validForm(passForm) { 
  if (passForm.passwd1.value == "") { 
    alert("you must enter a password");
    passForm.passwd1.focus();
    return false;
  } 
  if (passForm.passwd1.value != passForm.passwd2.value) { 
    alert("Entered passwords did not match");
    passForm.passwd1.focus();
    passForm.passwd1.select();
    return false;
  } 
  return true;
} 
</script> 

Body Code:

<form name="form" action="http://www.js-examples.com/" onsubmit="return validForm(this)">
Your name: <input type="text" name="textfield">
<BR>
Choose a password: <input type="password" name="passwd1" value="abc123">
<BR>
Verify password: <input type="password" name="passwd2" value="abc123">
<BR>
<input type="submit" value="Submit">  
<input type="reset"> 
</form> 

Times Viewed: 10

Leave a Reply

Your email address will not be published. Required fields are marked *