我正在使用 Benjamin Keen 的 RSV(真正简单的验证),但是我构建网站的方式我在页面底部有 javascript,这导致我正在验证的表单上出现可怕的内联 js 错误..
目前该表格有:
onSubmit="return RSV(this, rules);
我想把它改成这样:
registerForm.click(function(e){
e.preventDefault();
//alert("fired!");
return RSV($(this), rules);
});
但是控制台报告了一个 Uncaught ReferenceError: rules is not defined
我宁愿不使用内联 javascript,有没有人遇到过这个或理解到足以提供帮助 - anyhelp 将不胜感激。
这是使插件工作所需的其余代码的示例。
$(document).ready(function() {
$("#demo_form5").RSV({
onCompleteHandler: myOnComplete,
errorFieldClass: "errorFieldDemo5",
displayType: "display-html",
errorHTMLItemBullet: "— ",
rules: [
"required,first_name,Please enter your first name.",
"required,last_name,Please enter your last name.",
"required,email,Please enter your email address.",
"valid_email,email,Please enter a valid email address.",
"required,any_integer,Please enter your age.",
"digits_only,any_integer,The age field may only contain digits.",
"required,marital_status,Please enter your marital status."
]
});
});