Page Submits Twice

Discussion in 'ASP General' started by Umesh, Feb 24, 2006.

  1. Umesh

    Umesh Guest

    Hi

    Here is the sample code for my form, but problem is that it submitts
    twice in some cases when i click sub mit button.


    <script>
    function validateform (){
    //do a lot validation here, if validation failes, return false;

    //finaly this line
    return true;
    }
    </script>

    <form name="abc" action="any other apge" onsubmit = "return
    validateform();">



    <input type="submit" name="save" id="save">
    </form>

    Can any one help me?
     
    Umesh, Feb 24, 2006
    #1
    1. Advertising

  2. Umesh

    Paxton Guest

    Umesh wrote:
    > Hi
    >
    > Here is the sample code for my form, but problem is that it submitts
    > twice in some cases when i click sub mit button.
    >
    >
    > <script>
    > function validateform (){
    > //do a lot validation here, if validation failes, return false;
    >
    > //finaly this line
    > return true;
    > }
    > </script>
    >
    > <form name="abc" action="any other apge" onsubmit = "return
    > validateform();">
    >
    >
    >
    > <input type="submit" name="save" id="save">
    > </form>
    >
    > Can any one help me?


    You need to ask this in a javascript forum. It's a client side problem
    - ASP is purely server side.

    /P.
     
    Paxton, Feb 24, 2006
    #2
    1. Advertising

  3. Umesh

    Umesh Guest

    Any way! thanks for suggestion
     
    Umesh, Feb 24, 2006
    #3
  4. Umesh

    dNagel Guest

    <script>
    var isSubmitted = false;
    function validateform (){
    //do a lot validation here, if validation failes, return false;
    //finaly this line
    if (!isSubmitted)
    isSubmitted=true;
    return true;
    else
    return false;
    }
    </script>

    <form name="abc" action="any other apge" onsubmit = "return validateform();">
    <input type="submit" name="save" id="save">
    </form>
     
    dNagel, Feb 25, 2006
    #4
  5. Umesh

    Umesh Guest

    Hi ! Thanks for your time.

    I am not able to understand why this probelm occured. can u elaborate
    more.

    **Note submit button is clicked only once.
     
    Umesh, Feb 25, 2006
    #5
  6. Umesh

    Evertjan. Guest

    dNagel wrote on 25 feb 2006 in microsoft.public.inetserver.asp.general:

    > if (!isSubmitted)
    > isSubmitted=true;
    > return true;
    > else
    > return false;


    === Do not forget the {}

    ....
    if (!isSubmitted) {
    isSubmitted=true;
    return true;
    }
    else
    return false;
    ....

    === why use "else":

    ....
    if (!isSubmitted) {
    isSubmitted=true;
    return true;
    }
    return false;
    ....

    === why use an "if":

    ....
    var x = isSubmitted
    isSubmitted = true
    return !x
    ....

    ;-}

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 25, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Adams
    Replies:
    4
    Views:
    9,585
    Sagar@1
    Jan 22, 2013
  2. Umesh

    Page Submits twice

    Umesh, Feb 24, 2006, in forum: HTML
    Replies:
    3
    Views:
    627
    Alan J. Flavell
    Feb 24, 2006
  3. jpf
    Replies:
    0
    Views:
    104
  4. charlie_M
    Replies:
    6
    Views:
    133
    charlie_M
    Sep 23, 2005
  5. David Williams

    document.write submits page

    David Williams, Oct 18, 2007, in forum: Javascript
    Replies:
    1
    Views:
    95
    Dr J R Stockton
    Oct 18, 2007
Loading...

Share This Page