Reputation: 87
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:
<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!
Upvotes: 2
Views: 2947
Reputation: 4441
Use window.location.replace("url")
instead of window.location="report.html".
Upvotes: 1
Reputation: 1817
If you want to use window.location.replace("report.html") or window.location="report.html", first change the button type to 'button' i.e.,
<input type="button" value="Submit" id="submit">
For submit buttons, 'window.location' will not work.
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'.
Upvotes: 0