我被困在这里,我正在尝试验证具有相同名称的多个文本字段,但它仅验证第一个输入文本,其余部分没有显示。
<form id = "frm_org_id">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
</form>
JS
$('#frm_org_id').bootstrapValidator({
fields:{
'email_address[]':{
validators:{
notEmpty:{
message: ' required'
},
emailAddress:{
message: 'Invalid email address'
}
}
}
}
});
如何在键入时独立验证每个字段?
答案 0 :(得分:0)
您应该将输入标记放在div中,并使用class =“form-group”。 t.e:
<form id = "frm_org_id">
<div class="form-group">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
</div>
<div class="form-group">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
</div>
<div class="form-group">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
</div>
<div class="form-group">
<input type="text" name="email_address[]" placeholder="Email address" class="email_address">
</div>
</form>
工作示例请参阅: https://github.com/nghuuphuoc/bootstrapvalidator/blob/master/demo/multiple.html