Saturday 15 January 2011

php - Redirect if javascript condition is true not working -


I have a form and I agree to the fields in javascript functions. After verification, I want to redirect to another page. I am trying this type of:

  & lt; Form action = "" method = "post" name = "form" onsubmit = "return validate ()" & gt; User Name: & lt; Input type = "text" name = "realname" size = "19" & gt; & Lt; Span id = "realnameerror" & gt; & Lt; / Span & gt; & Lt; Br> E-mail: & lt; Input type = "text" name = "email" size = "25" & gt; & Lt; Span id = "email error" & gt; & Lt; / Span & gt; & Lt; Br> Phone: No: input type = "phoneono" name = "phoenino" maxlength = "10" size = "25" & gt; & Lt; Span id = "phononorrheaer" & gt; & Lt; / Span & gt; & Lt; Br> & Lt; Input type = "submit" value = "submit" & gt; & Lt; / Form & gt;   

And this is the code for verification:

  & lt; Script type = "text / javascript" & gt; Var hasFocus = false; Function CheckName (Form) / * Name Verification * / {...} Function Check Email (Form) / * Email Verification * / {...} Function for validphone (form) / * Phone verification * / {. ..} function valid () {hasFocus = false; Var form = document.forms ['form']; Var ary = [checkName, check e-mail, legitimate phone]; Var rtn = true; Var z0 = 0; (If (! Ary [z0] (form)) for {var z0 = 0; z0 & lt; ary.length; z0 ++} {rtn = false;}} if (RTN) {window.location = "http : //test.dev "; Return Return RTN;} and Return RTN;}    

The issue is that all Javascript functions are working correctly , I have received an error message, but it does not redirect me. The strange thing is that if I redirect to another script and do not verify it then it works. I do not know What I'm doing wrong I have tried to put my redirection on another function and call it like this:

  if (rtn) {redirection ();}   

but it still does not work window.location.href and document.location instead of window.location Href . I really think that I remember what's inside the script ... If you do some notice, please understand me. Thank you!

An attempt has been made to give me a statement and give a warning to me, and it appears for 2 seconds and then it redirects. If I do not keep that warning, then My radiation does not work. Here's the code:

  if (RTN) {window.location = "http://test.dev"; Warning (RTN);    

Some alerts inside this code

  if (RTN) {Warning ('you are here'); Window space = "http://test.dev"; Returns RTN; }   

If the warning comes out, you have come here. If not, then your first condition is wrong. That's the problem where we split out.

No comments:

Post a Comment