Form redirect after validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ziycon
    Contributor
    • Sep 2008
    • 384

    Form redirect after validation

    I have a form submitting and if it fails validation it stays on the same page with and error message, if it succeeds I need to forward on the data to another URL, can anyone suggest a way to to do this?

    I have the form up and working and validating fine, I just can pass the values onto another URL when all validation has succeeded??
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that depends on what the other page does with the data. the easiest way is certainly include the script, so that it can use the lingering (and validated) form data.

    Comment

    • Bharat383
      New Member
      • Aug 2011
      • 93

      #3
      Code:
      <form name="form1" action="page2.php" onsubmit="return check_validation()">
      <input type="text" name="txt1" value="">
      <br>
      <input type="text" name='txt2' value="">
      <br>
      <input type="submit" name="submit" value="SUBMIT">
      </form>
      
      <script type="text/javascript">
      function check_validation()
      {
         if(form1.txt1.value == "")
         {
             alert("Enter First Value !!!!");
             return false;
         }
         else if(form1.txt2.value == "")
         {
           alert("Enter Second value !!!!");
           return false;
         }
         else
         {
            return true;
         }
      }
      </script>
      Last edited by Dormilich; May 1 '12, 10:05 PM. Reason: Please use [CODE] [/CODE] tags when posting code.

      Comment

      Working...