Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 557
Vince Avatar asked Apr 15 '13 21:04

Vince


2 Answers

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!!!

like image 132
Vince Avatar answered Oct 13 '22 18:10

Vince


You can try this:

<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>

$("#signup").validationEngine();

..make sure that your jQuery is validation not validate

like image 1
Geoffrey Githaiga Avatar answered Oct 13 '22 20:10

Geoffrey Githaiga