jQuery Password match checking without using jQuery validate plugin
- Article
- Comment
jQuery Password match checking without using jQuery validate plugin. Let’s start working with the Password match using jQuery. And begin with HTML code , Here its,
<div class="form-group"> <label class="col-sm-3 control-label"> New Password</label> <div class="col-sm-6"> <input type="text" class="form-control" name="kv_teacher_password_new" id="kv_teacher_password_new" ></div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Confirm New Password</label> <div class="col-sm-6"> <input type="text" class="form-control" name="kv_teacher_confirm_password" id="kv_teacher_confirm_password" ></div> <p id="kv_teacher_password_p" style="color: red; " ></p> </div>
and the above code will be verified with the following jQuery ,
jQuery("#kv_teacher_confirm_password").keyup(kv_password_match);
Because we are going to check the password with confirm password. so we take the confirm password id and check keyup function , The below function will explain you more,
function kv_password_match() { var password = $("#kv_teacher_password_new").val(); var confirmPassword = $("#kv_teacher_confirm_password").val(); if (password != confirmPassword) $("#kv_teacher_password_p").html("Mismatch!"); else{ $("#kv_teacher_password_p").css("color", "green"); $("#kv_teacher_password_p").html("Match."); } }
That’s it. Now your code will check whether the password is matched or not.