我正在使用 CMS 系统,并且对我可以放置代码的位置有限制(目前)。我尝试使用的脚本必须在表单之后加载,并且它可以在 Dreamweaver 中成功运行。但是现在我将内容移到 CMS 中,我必须在标题中而不是在表单之后运行脚本。我试图在页面加载后使用它来加载它,如下所示:
<script>
$(document).ready(function() {
//You should create the validator only after the definition of the HTML form
var frmvalidator = new Validator("leadform");
frmvalidator.EnableOnPageErrorDisplaySingleBox();
frmvalidator.EnableMsgsTogether();
frmvalidator.addValidation("first_name","req","Please enter your first name.");
frmvalidator.addValidation("first_name","maxlen=40","Max length for first name is 40.");
frmvalidator.addValidation("first_name","alpha","Please enter your first name.");
frmvalidator.addValidation("last_name","req","Please enter your last name.");
frmvalidator.addValidation("last_name","maxlen=40","Max length for last name is 40.");
frmvalidator.addValidation("last_name","alpha","Please enter your last name.");
frmvalidator.addValidation("email","req","Please enter your e-mail address.");
frmvalidator.addValidation("email","email","Please enter your e-mail address.");
frmvalidator.addValidation("state","dontselect=0","Please select your state.");
});
</script>
我必须相信我只是写错了,但我找不到任何可以帮助我做到这一点的例子。显然我是一个菜鸟编码器 - 任何帮助将不胜感激。
谢谢。