gpt4 book ai didi

javascript - BootstrapValidator 验证具有相同名称的多个文本字段

转载 作者:行者123 更新时间:2023-12-01 05:27:45 29 4
gpt4 key购买 nike

我被困在这里,我正在尝试验证具有相同名称的多个文本字段,但它仅验证第一个输入文本,其余部分不显示。

<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'
}
}
}
}
});

如何在输入时独立验证每个字段?

最佳答案

您应该将输入标签放在 class="form-group"的 div 中。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

关于javascript - BootstrapValidator 验证具有相同名称的多个文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38938370/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com