Last updated August 19, 2010 16:35, by sdouglass
Customization
Customizing Error Display
You can override the JavaScript function used to display validation errors:
JSR303JSValidator.prototype.showValidationFeedback = function(failedRules) {
...
}
Make sure to include your code overriding that function after the jsr303js-codebase JavaScript.
Adding Support For Other Validation Annotations
To add support for other validation annotations, add corresponding JavaScript validation functions to the JSR303JSValidator.Rule.prototype.
JSR303JSValidator.Rule.prototype.After = function(value, params, fieldName, config) {
var valid = true;
if (value) {
var dateFormat = (config[fieldName] && config[fieldName].dateFormat ? config[fieldName].dateFormat : JSR303JSValidator.DateParser.defaultFormat);
try {
var dateValue = JSR303JSValidator.DateParser.parseDate(dateFormat, value);
var afterDate = JSR303JSValidator.DateParser.parseDate(dateFormat, params.format);
valid = dateValue && afterDate && dateValue.getTime() > afterDate.getTime();
} catch(e) {
JSR303JSValidator.Logger.log(e);
}
}
return valid;
},
If you need to pass extra configuration data to your custom validation functions, data that is not present in the annotation attributes, put it in the tag body JSON object.





