Page Submits twice

Discussion in 'HTML' started by Umesh, Feb 24, 2006.

  1. Umesh

    Umesh Guest

    Hi

    Here is the sample code for my form, but problem is that it submits
    twice in some cases when i click submit 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" value="save">
    </form>


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

  2. Even though your question has to do with Javascript and this is an HTML
    group, here's something that might help you.

    Get rid of the onsubmit parameter on the form.

    Use it on the button itself, like this:

    <input type="button" onclick="validateform()" name="save" id="save"
    value="save">

    Now inside the function itself, if the form is set to be submitted, do this
    just before the return true line:

    document.abc.submit();


    Hope this helps.
    Steve.


    "Umesh" <> wrote in message
    news:...
    > Hi
    >
    > Here is the sample code for my form, but problem is that it submits
    > twice in some cases when i click submit 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" value="save">
    > </form>
    >
    >
    > Can any one help me?
    >
    Steve Belanger, Feb 24, 2006
    #2
    1. Advertising

  3. In article <ZAELf.434$Ui.147@edtnps84>,
    says...
    > "Umesh" <> wrote in message
    > news:...
    > > Hi
    > >
    > > Here is the sample code for my form, but problem is that it submits
    > > twice in some cases when i click submit button.
    > >

    > Even though your question has to do with Javascript and this is an HTML
    > group, here's something that might help you.


    "Anything goes here. For anal HTML-only chat try CIWAH."

    > Get rid of the onsubmit parameter on the form.


    Pourquoi?

    > Use it on the button itself, like this:
    >
    > <input type="button" onclick="validateform()" name="save" id="save"
    > value="save">
    >
    > Now inside the function itself, if the form is set to be submitted, do this
    > just before the return true line:
    >
    > document.abc.submit();


    That's nuts. The OP now has a form that *won't* submit if JavaScript is
    enabled.

    The OP hasn't helped himself by failing to provide the appropriate code.
    The snippet he gave is useless. It like saying "I can't get a good
    picture on my TV. I've got a black cable and a blue one."

    --

    Hywel
    http://kibo.org.uk/
    Hywel Jenkins, Feb 24, 2006
    #3
  4. On Fri, 24 Feb 2006, Steve Belanger wrote:

    > Even though your question has to do with Javascript and this is an HTML
    > group, here's something that might help you.


    Translation: "beware of off-topic answers, which would likely be
    disputed if only they appeared in an appropriate group".
    Alan J. Flavell, Feb 24, 2006
    #4
    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,436
    Sagar@1
    Jan 22, 2013
  2. Umesh

    Page Submits Twice

    Umesh, Feb 24, 2006, in forum: ASP General
    Replies:
    5
    Views:
    130
    Evertjan.
    Feb 25, 2006
  3. jpf
    Replies:
    0
    Views:
    86
  4. charlie_M
    Replies:
    6
    Views:
    111
    charlie_M
    Sep 23, 2005
  5. David Williams

    document.write submits page

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

Share This Page