我正在使用jQuery验证插件在提交联系人表单之前对其进行验证。
问题是,在成功提交表单后,我应该重定向到“谢谢”页面。
这个是可能的吗?
我的验证代码如下所示:
$("#contactForm").validate({
//debug: true,
rules: {
fullname: "required",
email: {
required: true,
email: true
}
},
submitHandler: function(form) {
form.submit();
window.location.href = "/confirm.html";
}
});出于某些原因
window.location.href = "/confirm.html");
永远不会被执行。
谢谢你的帮忙,
安东尼
发布于 2014-05-29 02:50:40
经过反复尝试,我成功地将一个有效的表单提交为简单的表单后,重定向到了一个“谢谢”页面。这必须通过ajax调用来完成:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//ajax.aspnetcdn.com/ajax/jquery.validate/1.12.0/jquery.validate.min.js"></script>
<script>
$("#contactForm").validate({
rules: {
fullname: "required",
email: {
required: true,
email: true
}
},
submitHandler: function(form) {
$.ajax({
dataType: 'jsonp',
url: "http://getsimpleform.com/messages/ajax?form_api_token=my-secret-token",
data: $("#contactForm").serialize()
}).done(function() {
//callback which can be used to show a thank you message
//and reset the form
window.location.href = "/confirm.html";
});
}
});
</script>不,我可以验证联系人表单并将其提交到简单的表单服务,然后重定向到“谢谢”页面,所有这些都不需要任何服务器端代码:微笑:
https://stackoverflow.com/questions/23896845
复制相似问题