【发布时间】:2011-12-11 20:38:21
【问题描述】:
我在验证我的简单联系表单时遇到了麻烦,我不确定我做错了什么,我几乎完全从一个独立的演示中删除了代码,并遵循了 tut。我的代码有什么问题?
在头脑中: 更新的尝试
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>
开始,几乎就在结束之前 </head>
<script type="text/javascript">
SubmittingForm=function() {
alert("The form has been validated.");
}
$(document).ready(function() {
$("#fvujq-form1").validate({
submitHandler:function(form) {
SubmittingForm();
},
rules: {
name: "required", // simple rule, converted to {required:true}
email: { // compound rule
required: true,
email: true
},
url: {
url: true
},
comment: {
required: true
}
},
messages: {
comment: "Please enter a comment."
}
});
});
jQuery.validator.addMethod(
"selectNone",
function(value, element) {
if (element.value == "none") {
return false;
}
else return true;
},
"Please select an option."
);
$(document).ready(function() {
$("#fvujq-form2").validate({
submitHandler:function(form) {
SubmittingForm();
},
rules: {
sport: {
selectNone: true
}
}
});
});
</script>
靠近页面底部,表单标记:
<p style="font-style:italic; font-size:12px; font-weigh: normal; margin-top: -89px; margin-left: 33px;">Contact me written in a different language.</p> <img src="http://www.cameroncashwell.com/imgs/pointing-left.png" style="float: right; margin-right: 140px; margin-top: -89px;">
<div class="form-div">
<form id="fvujq-form1" style="font-size:22px; color:#333;" method="post" action="">
<div class="form-row"><span class="label">Name *</span><input type="text" name="name" /></div>
<div class="form-row"><span class="label">E-Mail *</span><input type="text" name="email" /></div>
<div class="form-row"><span class="label">URL</span><input type="text" name="url" /></div>
<div class="form-row"><span class="label">Your Comment *</span><textarea name="comment"></textarea></div>
<div class="form-row"><input class="submit" type="submit" value="Submit"></div>
</form>
</div>
另外 - 我应该在哪里拨打我的电子邮件地址以发送联系表单的内容?
【问题讨论】:
-
尝试只加载一次 jquery。
jquery-1.3.2.min.js或jquery-latest.js。并在 validate-plugin 之前加载 jquery。 -
还是什么都没有 - 上面我用我刚刚尝试在头部调用 jQuery 的方式编辑了 Q。 - 还有其他建议吗?
-
您的 jquery validate 链接不正确dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js 无法访问
标签: php javascript jquery html jquery-validate