jQuery验证name =“" name []"不工作 [英] Jquery Validate name="name[]" not working
本文介绍了jQuery验证name =“" name []"不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用bassistance.de的Validation插件,我想验证以下内容:
I'm using the Validation plugin from bassistance.de I want to validate the folowing:
<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:
And using this javascript:
$(document).ready(function() {
$("#form1").validate({
rules: {
vraag2[]: {required: true, minlength: 1}
},
messages: {
vraag2[]: "Make at least one choice"
}
});
});
但是它不起作用,它与[]
字符有关,如何在验证插件中使用这些字符?
But it's not working, It has to do with the []
characters how can I use those characters with the validation plugin?
谢谢!
埃德斯基
Thanks!
Edski
推荐答案
如果JavaScript对象文字中的名称包含非字母数字(或关键字),则必须加引号:
Names in JavaScript object literals must be quoted if they contain non-alphanumerics (or are keywords):
"vraag2[]": "Make at least one choice"
这篇关于jQuery验证name =“" name []"不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文