In this below script,Form validation password match in jquery
HTML
<form id="details" action=''>
<input type='text' id='password'/>
<input type='text' id='repeatpass'/>
<span id="matchpass"></span>
</form>
Script
<form id="details" action=''>
<input type='text' id='password'/>
<input type='text' id='repeatpass'/>
<span id="matchpass"></span>
</form>
Script
function onLoad() {
$("#password").keyup(passCheck);
$("#repeatpass").keyup(passCheck);
}
function passCheck() {
var password = $("#password").val();
var repeatpass = $("#repeatpass").val();
if (password == repeatpass) {
$("#matchpass").text("Passwords match");
$("#matchpass").addClass("valid");
$("#matchpass").removeClass("error");
$("#details").submit();
} else {
$("#matchpass").text("Passwords donot match");
$("#matchpass").addClass("error");
$("#matchpass").removeClass("valid");
}
}
$(document).ready(onLoad);
No comments:
Post a Comment