26 lines
864 B
JavaScript
26 lines
864 B
JavaScript
(function ($) {
|
|
if($.validator && $.validator.unobtrusive){
|
|
$.validator.unobtrusive.options = {
|
|
errorClass: 'is-invalid',
|
|
validClass: 'is-valid',
|
|
errorElement: 'span',
|
|
errorPlacement: function (error, element) {
|
|
error.addClass('invalid-feedback');
|
|
|
|
var valmsgFor = element[0].id;
|
|
if (element[0].type === 'radio') {
|
|
valmsgFor = element[0].name.replace(/\..*/g, "");
|
|
}
|
|
|
|
var errElement =
|
|
$('[data-valmsg-for="' + valmsgFor + '"]');
|
|
|
|
errElement.after(error);
|
|
}
|
|
};
|
|
}
|
|
else {
|
|
console.warn('$.validator is not defined. Please load this library **after** loading jquery.validate.js and jquery.validate.unobtrusive.js');
|
|
}
|
|
})(jQuery);
|