Submitting Forms

Discussion in 'Javascript' started by Mtek, Jun 1, 2008.

  1. Mtek

    Mtek Guest

    Hi,

    I have a generic routine that is called by many forms, and probably by
    many browsers. The javascript performs some validation on the form
    passed in and then issues the command 'submit()'.

    I am getting an error that says "submit() is not defined"

    I'm lost. This is a generic routine, so passing in the form is a
    must.......

    Any thoughts or suggestions?

    Thanks!!

    john
     
    Mtek, Jun 1, 2008
    #1
    1. Advertising

  2. Rumney wrote:

    > ??? wrote:
    >> I have a generic routine that is called by many forms, and probably by
    >> many browsers.  The javascript performs some validation on the form
    >> passed in and then issues the command 'submit()'.

    >
    >> I am getting an error that says "submit() is not defined"

    >
    > submit() is a method on a form object... you can't just call it on its
    > own


    Yes, but it usually indicates a less optimal design too. The
    recommended way is to add an onSubmit-event to the form, and then
    prevent the form to be submitted if the checks are not okay, in stead
    of executing a submit()-command when the checks _are_ okay.

    Wrong:

    <form method="get" action="script.asp">
    <input type="button" onClick="if (...) document.forms[0].submit()">
    </form>

    Right:

    <form method="get" action="script.asp"
    onSubmit="if (...) return false">
    <input type="submit">
    </form>

    The logic for the checks is then reversed.

    Hope this helps,

    --
    Bart
     
    Bart Van der Donck, Jun 2, 2008
    #2
    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. msnews.microsoft.com

    Forms not submitting in some browsers! Help!

    msnews.microsoft.com, May 28, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    505
    Anachostic
    May 30, 2004
  2. Mark Fisher

    Submitting ASP.NET Forms

    Mark Fisher, Oct 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    439
    Steve C. Orr [MVP, MCSD]
    Oct 23, 2004
  3. =?Utf-8?B?RHIuIFBhdWwgQ2Flc2FyIC0gQ291bGxCeXRlIChV

    FORMS NOT SUBMITTING DUE, IIS CRASH: appSettings KEY in web.confi

    =?Utf-8?B?RHIuIFBhdWwgQ2Flc2FyIC0gQ291bGxCeXRlIChV, Nov 4, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    555
    =?Utf-8?B?RHIuIFBhdWwgQ2Flc2FyIC0gQ291bGxCeXRlIChV
    Nov 4, 2005
  4. NeoPhreak

    Submitting Multiple Forms

    NeoPhreak, Oct 21, 2003, in forum: HTML
    Replies:
    9
    Views:
    510
    Whitecrest
    Oct 22, 2003
  5. Merlin

    submitting forms over get

    Merlin, Sep 25, 2005, in forum: HTML
    Replies:
    2
    Views:
    416
    Mitja Trampus
    Sep 25, 2005
Loading...

Share This Page