I am trying to work with jQuery validation plugin without any problems .
I do not understand how to set the specific input to check:
<script>
$(document).ready(function(){
$("#form-id").validate({
username_id: { required:true },
password_id: { required:true, minlength:8 },
confirm_id: { required:true, minlength:8, equalTo:"#password_id" }
},
messages: {
username_id: "Missing username",
password_id: {
required: "Missing password",
minlength: "Password short (5 chars min required)"
},
confirm_id: {
required: "Missing password",
minlength: "Password short (5 chars min required)",
equalTo: "Password mismatch"
}
});
});
</script>
<form id="form-id" etc>
<input id="username_id" name="data[User][username]"><br>
<input id="password_id" name="data[User][password]"><br>
<input id="confirm_id" name="data[User][confirm]"><br>
<input type="submit" value="Register">
</form>
Does this validator always write class='valid'in the input test i? I am sure that the problem is in the name of the object, because I do not understand if I have to install idor name attributefor the plugin to work correctly.
Every tutorial I found always uses the same names for the id and name attribute, so I cannot figure out where I am going wrong.
I also have a problem with the name attribute from cakephp, so mine input form name attributeis similar data[User][username], and I don't know how to use it with the plugin.
How can i fix this?
PS: jquery 1.6.1, , 1.3.2, firebug .