非常简单的示例,当我在“必需”中使用应该在实际表单验证上运行但它也在页面加载时执行的函数时。
问题是如何避免它并使其仅在实际验证时才调用内部所需的其他函数。
$("form").validate({
rules : {
testinput: {
required: runFunction('hello world')
}
});
function runFunction(a){
console.log(a);
}