[Javascript] Q on grabbing ONSUBMIT..

David Lovering dlovering at gazos.com
Fri Oct 31 07:10:50 CST 2003


It's early.  I didn't catch the bit about not wanting the onSubmit attribute
defined in the form header.

In theory, it should be possible to define the onsubmit at the document
level (above that of the form) in the JavaScript
header code

document.onsubmit = blah-blah-blah

or (more syntacticly correct)

document.forms[0].onsubmit = blah-blah-blah

Of course, if you want to work smoothly with IE browsers you'll have to do
it with the "void function { functionname(params) }" syntax.  Go figure.

-- Dave Lovering

----- Original Message ----- 
From: "David Lovering" <dlovering at gazos.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Friday, October 31, 2003 5:59 AM
Subject: Re: [Javascript] Q on grabbing ONSUBMIT..


> First off, assigning the action to a null string doesn't work very well
> across a wide cross-section of browsers.  A much better method is as
> follows:
>
> action='javascript:void(null)'
>
> To kill the submission of the form (which you've effectively set in motion
> by setting the action as described), the routine called by onSubmit (or
> whatever name-variation is this weeks W3C favorite) merely needs to return
> false.   At least that's the way I interpret the fine print, and so far my
> interpretation hasn't blown up any of my various web-apps.
>
> -- Dave Lovering
>
> ----- Original Message ----- 
> From: "Walter Torres" <walter at torres.ws>
> To: "[JavaScript List]" <javascript at LaTech.edu>
> Sent: Friday, October 31, 2003 3:28 AM
> Subject: [Javascript] Q on grabbing ONSUBMIT..
>
>
> > I have this bit...
> >
> >
> > <form action=""
> >       id="demo"
> >       name="demo"
> >       method="post"
> >       onsubmit="return doForm ( this, document )">
> >
> > It works just fine.
> >
> > This method checks some things and then returns a TRUE or FALSE, and the
> > FORM is sent based upon that returned value.
> >
> > Fine, but...
> >
> > I thought I knew how, but I'm at a loss this early in the morning.
> >
> > How can I "grab" the 'onSubmit' event, do my checks and then have my
> method
> > decide to send the form or not.
> >
> > In other words, I don't want to have the 'onSubmit' attribute on the
FORM
> > Object Tag.
> >
> > I just want to INCLUDE a JS file, and the FORM on that page will be
> handled.
> >
> > Oh, also, it needs to handle multiple FORMS on a single page.
> >
> > Any ideas form those who are brighter than I?
> >
> > Thanks
> >
> > Walter
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list