$(doc开发者_开发问答ument).ready(function(){
var min="1.2.2";
$.validator.addMethod('xyz', function(value, element, param) {
alert(min);
min=minAorB();// I want to call a function which will return the minimum among A and B.
alert(min);
return (validateAnmcComp(value,param));
}, "Please enter a value less than or equal to "+min);
})(jQuery);
I want the message to be displayed as "Please enter a value less than or equal to 1.4.5"
Would this help?
$(document).ready(function($) {
function createMinValidator(min) {
return function(value, element, param) {
// use min as required
return (validateAnmcComp(value, param));
};
}
var min = "1.4.5";
var msg = "Please enter a value less than or equal to " + min;
$.validator.addMethod('xyz', createMinValidator(min), msg);
});
精彩评论