我有具有用于即如何验证其具有名称在阵列使用jquery.validate.min.js
<div class="form-group">
<label class="col-sm-2 control-label">
<span style="color: red;">*</span>
Title</label>
<div class="col-sm-8 general-title tooltip-demo">
<input type="text" name="form[1][title]" id="title" value="" size="64" class="form-control" data-toggle="tooltip" data-placement="top" data-html="true" title="" required="required" data-original-title="Enter Notification Title"> </div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">
<span style="color: red;">*</span>
Title 2</label>
<div class="col-sm-8 general-title tooltip-demo">
<input type="text" name="form[2][title]" id="title" value="" size="64" class="form-control" data-toggle="tooltip" data-placement="top" data-html="true" title="" required="required" data-original-title="Enter Notification Title"> </div>
</div>
我知道,我可以array
name
属性input
标记字段tyepe输入字段做验证像
$(document).ready(function() {
$("#frmforgot").validate({
rules: {
form[1][title]: {
required: true
},
form[2][title]: {
required: true
}
}
});
});
但我不想分隔每个验证规则,因为我有30个不同的领域,所以我不想写30 * 2
规则。
如果有人知道简单的方法,请给我建议。
在此先感谢
非常好的答案... !!! ..我已经删除了我的:) –
如果我有电子邮件字段和所需,电子邮件验证。也在你的答案“输入[名称^ =形式]”这是不是阵列格式,所以我不认为它的作品 –
为什么它会在数组格式?规则是一个对象,即使在你的例子中。如果您有其他要求,请更新问题。 – dmoo