Using this jQuery validation plugin.
http://www.benjaminkeen.com/software/rsv/jquery/index.php
I want to validate a checkbox group with JS, but when i use the statement:
rules.push("required,accomodationtype[],Please check all that apply");
or
rules.push("required,accomodationtype\[\],Please check all that apply");
for this kind of checkbox group:
<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">
It doesn't validate and it immediately posts the form. I am not sure if I am doing something wrong.
Update
I have custom error handler. Tried Alper's suggestion getting this error message: 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;
}