I follow the suggestion here on how to customize the validation errors of the jQuery validate and it works well.
But right now, I am trying to change the validation message only to specific fields.
I tried assigning a class to the field and did something like but it doesn't seem to be working:
customRules: function() {
if (typeof $.fn.validate !== 'undefined') {
$.validator.addMethod("check_for_empty", function(value, element, param) {
var $ele = $(element);
return ! this.optional(element) && value == '';
}, $.validator.format("Custom required validation message."));
}
if ( $('.custom-required-validation-message input').length ) {
$('.custom-required-validation-message input').rules( 'add', {
check_for_empty: true
});
}
}
Any input would be appreciated. Thanks!