I am using Jquery form validation plug-in to validate inputs within a form before submitting, there are some input elements which are named as "question1”, "question2", "question3",..., they are dynamically generated. So how to validate these input elements within the Jquery plugin function validate()? I need a means to select them first.
$(document).ready(function() {
$("#formname").validate({
rules: {
title: {
required: true,
minlength:40
},
content: {
required: true,
minlength:100,
maxlength:2000
}
},
messages: {
}
});
});
Title, content are other input elements within the same form, they are not dynamically generated so they are easy to validate, just by their name. So how to validate "question1", "question2", "question3",..., certainly I can write like this:
question1: {
required: true,
minlength:40
},
question2: {
required: true,
minlength:40
},
question3: {
required: true,
minlength:40
},
...
But, as I said, these input elements are dynamically generated, I can not predict how many "questionn" there are. So how to do the job?