Reputation: 1356
i one working on rails and rails follows some naming convention of input elements, i am not able to validate my form using query validation.
my form is like this
<form method="post">
<input id="user_id" name="user[id]" type="text" />
<input type="submit" value ="login" />
</form>
var myrules = {
user[id] : {
required : true
}
};
its not working this way :(
how can i define rule for input for name 'user[id]', as jquery create some variable based on the name of the elements, what should be the name of variable which jquery validator will create for this element
Upvotes: 0
Views: 132
Reputation: 15403
You need to wrap the name of the input (in this case user[id]) in quotes
var myrules = {
"user\[id\]" : {
required : true
}
};
Learn jQuery Validation Plugin
Upvotes: 0
Reputation: 20418
you missed quotes
Try this
rules : {
"user\[id\]" : {
required : true
}
};
Upvotes: 0
Reputation: 1356
this should work like this
rules : {
"user\[id\]" : {
required : true
}
};
Upvotes: 1