Search code examples
jqueryformsjquery-validation-engine

jQuery form validation engine not working properly on equals


I just downloaded the jQuery plugin form validation engine. Everything worked good so far until I check if the passwords match. If both the password field and the confirm password field is left blank, the error message "Fields don't match" doesn't come up, which is fine since they do match. But when I type something in the password text box and type the same password in the confirm text box, the error message stays up "Fields do not match" when clearly they do.

HTML:

<form id = "signup">
  <label>Password:</label>
  <input type = "password" name = "txtPassword" id = "txtPassword" class = "validate[required,minSize[6],maxSize[50]]"/>
  <label>Confirm Password:</label>
  <input type = "password" name = "txtCPassword" id = "txtCPassword" class = "validate[required,equals[txtPassword]]"/>
</form>

My JS file:

$(document).ready(function(){
    $("#signup").validateEngine();
});

In my HTML file, I have links to the validation css styles, as well as the validation engine and the en language.


Solution

  • I've found the solution to my question. For some reason I had to input elements with the same id, therefore it wasn't taking the value of the input field that I wanted. :P Simple but dangerous programming mistake. If anyone else runs into this problem, make sure your id's are unique!!!