html - redirect after form submit jquery -


i have submit form target = _blank , redirect page other.

html

<form id="registration_form" name="registration_form" method="post" action="actionurl" target="_blank">     <input type="button" name="submit" id="submit" value="submit" /> </form> 

jquery

$(document).ready( function() {    $('#registration_form').submit( function(e)    {       var flag=validate();       if(flag)           $(location).attr('href',redirectionurl);       return flag;    });     $("#submit").click(function(){       $('#registration_form').submit(); // triggers submit event    }); }); 

if change button type submit form submitting per validation flag redirection doesn't work.

if use button instead of submit redirection takes place form not submitting.

where have been wrong. help.

thank you.

i think in hard way, since define target _blank, submit forum later, suggest validation on server side , not on jquery. html code should that:

<form id="registration_form" name="registration_form" method="post" action="actionurl" target="_blank">     <input type=hidden name="flag_input" value="false">     <input type="button" name="submit" id="submit" value="submit" /> </form> 

and jquery code:

$(document).ready( function() {    $('#registration_form').submit( function(e)    {       var flag=validate();       if(flag)           $("#flag_input").val("true")    });     $("#submit").click(function(){       $('#registration_form').submit();     }); }); 

and server flag_input - if true, redirect, if not, user have fill forum again. if don't want redirect @ all, can use ajax.

edit: , on server side:(i don't know langues use basic that:)

if (flag_input==true) - generate pdf , redirect x

else - redirect y(the forum page)

let me know if helped. goodluck!


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -