I'm using Jquery Form Validator to validate my registration form for my site and while it does validate successfully, it refreshes the page when I click submit and not redirect directly to another page. Here's what I have:
我正在使用Jquery Form Validator来验证我的网站的注册表单,并且当它确实成功验证时,它会在我单击提交时刷新页面,而不是直接重定向到另一个页面。这就是我所拥有的:
<script>
$(document).ready(function() {
$("#formID").validationEngine({
submitHandler: function(form){
window.location="report.html"
}
});
function validate2fields(){
if($("#addressl1").val() =="" || $("#addressl2").val() == ""){
return false;
}else{
return true;
}
}
});
</script>
I'm using a simple "submit" button and I've tried adding the link into the button but that didn't work at all. Here it is:
我正在使用一个简单的“提交”按钮,我尝试将链接添加到按钮,但这根本不起作用。这里是:
<input type="submit" value="Submit" id="submit">
I'm a beginner at this so I apologize if I've used the wrong terminology. Thanks in advance!
我是初学者,所以如果我使用了错误的术语,我会道歉。提前致谢!
2 个解决方案
#1
1
Use window.location.replace("url")
instead of window.location="report.html".
使用window.location.replace(“url”)而不是window.location =“report.html”。
Hope this helps you.
希望这对你有所帮助。
#2
0
If you want to use window.location.replace("report.html") or window.location="report.html", first change the button type to 'button' i.e.,
如果要使用window.location.replace(“report.html”)或window.location =“report.html”,请先将按钮类型更改为“按钮”,即
<input type="button" value="Submit" id="submit">
For submit buttons, 'window.location' will not work.
对于提交按钮,'window.location'将不起作用。
Otherwise use this method
否则使用此方法
$("#form").attr("action","report.html");
$("#form").attr("method", "post");
$("#form").submit();
In this method also button type should be 'button', not 'submit'.
在这种方法中,按钮类型也应该是“按钮”,而不是“提交”。
#1
1
Use window.location.replace("url")
instead of window.location="report.html".
使用window.location.replace(“url”)而不是window.location =“report.html”。
Hope this helps you.
希望这对你有所帮助。
#2
0
If you want to use window.location.replace("report.html") or window.location="report.html", first change the button type to 'button' i.e.,
如果要使用window.location.replace(“report.html”)或window.location =“report.html”,请先将按钮类型更改为“按钮”,即
<input type="button" value="Submit" id="submit">
For submit buttons, 'window.location' will not work.
对于提交按钮,'window.location'将不起作用。
Otherwise use this method
否则使用此方法
$("#form").attr("action","report.html");
$("#form").attr("method", "post");
$("#form").submit();
In this method also button type should be 'button', not 'submit'.
在这种方法中,按钮类型也应该是“按钮”,而不是“提交”。