Oct 22, 2014

Password and Retype Password Validation Using Java Script

Following code will help you to validate the password and retype password.Simply we have used pure java script. In the following example when you entering password it will clear the retype password text. When you entering the text for retype password field it will call the checkPasswordMatch() function to validate the password and retype password.






<html>
  <head>
<title>Easy Code Stuff - Password & Retype Password Validation Using Java Script</title>
<script>
function clearRetypePassword(){
var repassword = document.getElementById('repassword');
var errorspan = document.getElementById('reTypePasswordErrorSpan');

repassword.style.border = "2px solid #C58917";
errorspan.style.color = "#C58917";
errorspan.innerHTML = "Retype The Password"
}

function checkPasswordMatch()
{
var password = document.getElementById('password');
var repassword = document.getElementById('repassword');
var errorspan = document.getElementById('reTypePasswordErrorSpan');

if(password.value == repassword.value){
repassword.style.border = "2px solid #41A317";
errorspan.style.color = "#41A317";
errorspan.innerHTML = "Passwords Match!"
}else{
repassword.style.border = "2px solid #FF2400";
errorspan.style.color = "#FF2400";
errorspan.innerHTML = "Passwords Does Not Match!"
}
    }
</script>
  </head>
<body>
<label for="password">Password : </label>
<input type="password" id="password" onkeyup="clearRetypePassword(); return false;"><br/>
<label for="repassword">Retype Password : </label>
<input type="password" id="repassword" onkeyup="checkPasswordMatch(); return false;">
<span id="reTypePasswordErrorSpan"></span>
</body>
</html>






No comments:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...