使用此jQuery验证插件。jQuery复选框验证问题
http://www.benjaminkeen.com/software/rsv/jquery/index.php
我想验证与JS复选框组,但是当我使用的语句:
rules.push("required,accomodationtype[],Please check all that apply");
或
rules.push("required,accomodationtype\[\],Please check all that apply");
这类复选框组:
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_0" value="hotel1">Hotel1<BR>
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_1" value="hotel2">Hotel2<BR>
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_2" value="hotel3">Hotel3<BR>
<INPUT type="checkbox" name="accomodationtype[]" id="accomodationtype_5" value="other"> Other (please specify)<BR>
<INPUT type="text" name="accomodationtypeother" id="accomodationtypeother">
它不验证,它立即发布表单。我不确定我是否做错了什么。
有人可以帮助这种情况吗?
UPDATE 我有自定义错误处理程序。试图阿尔珀的建议收到此错误信息:errorInfo[i][0].focus is not a function
function errorHandler3(f, errorInfo)
{
for (var i=0; i<errorInfo.length; i++)
{
// errorInfo[i][0] contains the form field node that just failed the validation, e.g.
errorInfo[i][0].focus();
// errorInfo[i][1] contains the error string to display for this failed field, e.g.
$.notifyBar({
cls: "error",
html: errorInfo[i][1]
});
}
if (errorInfo.length == 0) tcrform_submit();
return false;
}
尝试在jQuery调用中使用accomationtype而不是accomationtype []? – Cyclonecode
它给出了错误,这个字段不存在 –
具有讽刺意味的是,你链接的验证器的不太全面的演示页面没有显示如何验证复选框或复选框组。如果您使用该验证器,我会联系作者。 –