Advertisement
rodro1

Confirm Password match validation html5

Mar 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. //confirm password match
  3. var new_password = document.getElementById("new_password")
  4.   , confirm_password = document.getElementById("confirm_password");
  5.  
  6. function validatePassword(){
  7.   if(new_password.value != confirm_password.value) {
  8.     confirm_password.setCustomValidity("Passwords Don't Match");
  9.   } else {
  10.     confirm_password.setCustomValidity('');
  11.   }
  12. }
  13. new_password.onchange = validatePassword;
  14. confirm_password.onkeyup = validatePassword;
  15. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement