When using the script in a spring based application which might have nested objects as form fields; we have to use the notation as follows
<spring:bind path="demographicInfo.gender">
<c:forEach var="gender" items="${genderList}">
<li><label for=""><input name="demographicInfo.gender" type="radio" class="required" value="${gender}">${gender.gender}</input></label></li>
</c:forEach>
</spring:bind>
if (field.is(':radio')) {
name = field.attr('name');
if ($("input[name=" + name + "]:checked").length) {
return true;
}
return i18n('req_radio', caption);
}
if (field.is(':checkbox')) {
name = field.attr('name');
if (field.is(":checked")) {
return true;
}
return i18n('req_checkbox', caption);
var name;
if (field.is(':radio')) {
var rawName = field.attr('name');
if (~rawName.indexOf('.')) {
console.log("escaping . chanracter");
name = rawName.replace(".", "\\.");
console.log(name);
} else
name = rawName;
if ($("input[name=" + name + "]:checked").length) {
return true;
}
return i18n('req_radio', caption);
}
if (field.is(':checkbox')) {
if (field.is(":checked")) {
return true;
}
return i18n('req_checkbox', caption);
}
Not sure if this is the best way to do it; but this support should be there IMHO. Also the expression name = field.attr('name') is unnecessary in the if block for checkbox.