24
我想用jQuery驗證插件使用自定義驗證器。 但是,我不確定如何將多個參數傳遞給驗證方法? 我試過使用(2,3),花括號和組合,但我失敗了。jQuery驗證插件自定義方法。多個參數
這是代碼 - ?????標誌着區域,我需要了解的信息:
$(document).ready(function() {
jQuery.validator.addMethod("math", function(value, element, params) {
return this.optional(element) || value == params[0] + params[1];
}, jQuery.format("Please enter the correct value for {0} + {1}"));
$("#form_register").validate({
debug: true,
rules: {
inputEl: { required: true, math: ???? }
},
messages: {
inputEl: { required: "Required", math: "Incorrect result" }
}
});
});
做的竅門。謝謝。 – BuzzBubba 2009-09-02 10:18:29