<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:
Post a Comment