我正在使用Formvalidation.io插件,这个插件非常适合
<input type="text" name="url[]" required />使用以下验证代码
'url[]': {
validators: {
stringLength: {
min: 4
}
}
},但是当使用“预定义”索引时
<input type="text" name="url[1]" required />以下验证不起作用
'url[]': {
validators: {
stringLength: {
min: 4
}
}
},它使用验证代码中的固定索引(参见下面的代码)。
'url[1]': {
validators: {
stringLength: {
min: 4
}
}
},但是,我动态地添加了一个未知索引的字段。因此,在验证代码中使用固定索引不是一个选项。
发布于 2015-12-23 16:22:28
我认为您要查找的内容的答案是在这页面上,然后是第二节“不同名称的输入”。
在那里你可以验证你的css类
<fieldname>: {
//the input css class
selector: '<.cssClass>',
// The field is placed inside .col-xs-6 div instead of .form-group
row: '.col-xs-6',
validators: {
<your validator>
}
}发布于 2022-03-29 22:23:34
在formvalidation.io版本1.9.0中,这是对我有用的内容:
<input type="text" name="myvar[1]" />
<input type="text" name="myvar[2]" />
<input type="text" name="myvar[3]" />使用selector选项验证以"myvar[“开头的所有变量名
'this_can_be_anything': {
selector: 'input[name^="myvar["]',
validators: {
stringLength: {
min: 4
}
}
},更多细节可以在这里找到:https://formvalidation.io/guide/getting-started/field-selector/
https://stackoverflow.com/questions/34439576
复制相似问题