假设我有这样的事情:
<input type="text" class="..." placeholder="Title" name="box[0][title]" value="">
<input type="text" class="..." placeholder="Description" name="box[0][descrip]" value="">
如果添加了第二个“框”,则为:
<input type="text" class="..." placeholder="Title" name="box[1][title]" value="">
<input type="text" class="..." placeholder="Description" name="box[1][descrip]" value="">
如果添加更多框,我该如何添加验证?
jQuery('form').validate({
rules: {
'box[0][title]': {
required: true
},
'box[0][descrip]': {
required: true
},
//How can I add rules if a second box is added?