I want to change the default behavior for the jquery.validate.unobtrusive.js
I want to be able to change options like the error message placement or highlight a field when an error is happening , etc
all that I could do using the jquery.validate
plugin alone. Just change some of the validate
method options like highlight
or errorPlacement
so I want to override some of the functionality of the unobtrusive validation , is it possible without changing the jquery.validate.unobtrusive.js
file
You could fetch the native validator from the form data and then subscribe to any standard option. For example errorPlacement
:
$(function() {
var validator = $('form').data('validator');
validator.settings.errorPlacement = function(error, element) {
// do your custom error placement
};
validator.settings.highlight = function(element, errorClass) {
// do your custom error highlight
};
});