我正在使用带有验证器插件的jQuery,想用自己的一个替换“必需”验证器,这很容易:
jQuery.validator.addMethod("required", function(value, element, param) {
return myRequired(value, element, param);
}, jQuery.validator.messages.required);
这结果是递归的:
jQuery.validator.addMethod("required", function(value, element, param) {
// handle comboboxes with empty guids
if (someTest(element)) {
return myRequired(value, element, param);
}
return jQuery.validator.methods.required(value, element, param);
}, jQuery.validator.messages.required);
发布于 2018-08-29 10:05:01
这样试试:
Function.prototype.clone=function(){
return eval( '('+this.toString()+')' );
}
Object.prototype.clone=function(){
return eval( '('+this.toString()+')' );
}
发布于 2018-08-29 11:13:59
Function.prototype.clone = function() {
var fct = this;
var clone = function() {
return fct.apply(this, arguments);
};
clone.prototype = fct.prototype;
for (property in fct) {
if (fct.hasOwnProperty(property) && property !== 'prototype') {
clone[property] = fct[property];
}
}
return clone;
};
https://stackoverflow.com/questions/-100000685
复制相似问题