I have a field on my form that is required if another field contains a certain value but otherwise is optional. I have set up a custom validator as follows:
document.formvalidator.setHandler('description', function(value) {
if (comment_required)
{
return value.length;
}
else
{
return true;
}
});
where "comment_required" is set according to whether or not the field is mandatory.
If I define the field with a class of "validate-description" (only) it is never validated. If I set a class of "required validate-description" (which is what the Joomla documentation says I should do) the it seems the "required" cuts in first, and the user is not allowed a blank field.