我正在使用来自bassistance.de的Validation插件我想验证以下内容:
<form class="cmxform" id="form1" action="ufm/mailit.php" method="post">
<fieldset>
<input type="checkbox" value="namea" name="name[]" id="namea" /> <label for="namea">Name a</label>
<input type="checkbox" value="nameb" name="name[]" id="nameb" /> <label for="nameb">Name b</label>
<input type="checkbox" value="namec" name="name[]" id="namec" /> <label for="namec">Name c</label>
<button type="submit" id="RegisterButton" name="ButtonValue" value="Aanvragen">Submit</button>
</fieldset>
</form>
并使用此javascript:
$(document).ready(function() {
$("#form1").validate({
rules: {
vraag2[]: {required: true, minlength: 1}
},
messages: {
vraag2[]: "Make at least one choice"
}
});
});
但它不起作用,它与[]
字符有关,如何将这些字符与验证插件一起使用?
谢谢!
Edski
答案 0 :(得分:6)
如果JavaScript对象文字中的名称包含非字母数字(或者是关键字),则必须引用它们:
"vraag2[]": "Make at least one choice"