4
只是不知道是否有覆蓋的亮點和使用MVC3 jquery.validate.unobtrusive時unhighlight選項,而無需編輯源js文件的方式...MVC3 jquery.validate.unobtrusive覆蓋沒有編輯源代碼的選項?
我已經嘗試過:
var elementToValidate = $(element);
var form = $(element.form);
if (form.length) {
//elementToValidate.valid();
form.validate({
highlight: function (element, errorClass, validClass) {
$(element).removeClass(errorClass);
$(element).closest('td').addClass('alert-error error');
}, unhighlight: function (element, errorClass, validClass) {
$(element).removeClass(errorClass);
$(element).closest('td').addClass('alert-error error');
}
});
}
但亮點和unhighlight沒有被重載,除非從我的腳本,刪除不顯眼庫..
如果我編輯jquery.validate.unobtrusive.js源這似乎只是很好地工作:
function validationInfo(form) {
var $form = $(form),
result = $form.data(data_validation);
if (!result) {
result = {
options: { // options structure passed to jQuery Validate's validate() method
errorClass: "input-validation-error",
errorElement: "span",
errorPlacement: $.proxy(onError, form),
invalidHandler: $.proxy(onErrors, form),
messages: {},
rules: {},
success: $.proxy(onSuccess, form),
highlight: function (element, errorClass, validClass) {
$(element).removeClass(errorClass);
$(element).closest('td').addClass('alert-error error');
}, unhighlight: function (element, errorClass, validClass) {
$(element).removeClass(errorClass);
$(element).closest('td').addClass('alert-error error');
}
},
attachValidation: function() {
$form.validate(this.options);
},
validate: function() { // a validation function that is called by unobtrusive Ajax
$form.validate();
return $form.valid();
}
};
$form.data(data_validation, result);
}
return result;
}
個
只是想知道,如果有人想出了一個方法來覆蓋的選項,而無需修改源..
乾杯