I'm currently trying to set up a registration page on my website but I have a problem: My JS script does not act like I want it to do
Here is my script:
function checkPasswordMatch() { var password = $("#password").val(); var confirmPassword = $("#retypepassword").val(); if (password != confirmPassword) { $("#pass").html("Passwords do not match!"); $("#submit").attr("disabled"); } else { $("#pass").html("Password match."); $("#submit").removeAttr("disabled"); } } $(document).ready(function () { $("#retypepassword").keyup(checkPasswordMatch); }); And my html code:
<INPUT class="btn btn-primary" type="submit" id="submit" name="" value="Register" disabled /> So in my opinion it's supposed to add the "disabled" attribute when passwords do not match and remove it when they match but here is what happen :
When the passwords match, the disabled state is removed but if they do not match (if they are modified for any reason for instance) they state does not come back again