Reputation: 13
I use demo on this link: http://runnable.com/UZJ24Io3XEw2AABU/how-to-validate-forms-in-jquery-for-validation
Example, I have the jQuery check validation:
$("#comment-reply-form").validate({
// Specify the validation rules
rules: {
UserName: {
required: true,
minlength: 5
},
CommentContent: {
required: true,
minlength: 15
},
},
// Specify the validation error messages
messages: {
UserName: {
required: "input your name",
minlength: "least 5 character"
},
CommentContent: {
required: "input your comment",
minlength: "least 15 character"
},
},
submitHandler: function (form) {
form.submit();
}
});
And I have multiple form in loop foreach, so how can I check specifically a "element id" in the specific form?
Upvotes: 1
Views: 2114
Reputation: 108
Instead of using $("#comment-reply-form").validate()
, you should use:
$('form').each(function(){
$(this).validate({
)};
)};
Upvotes: 5