HighDots Forums  

Submitting Forms

Javascript JavaScript language (comp.lang.javascript)


Discuss Submitting Forms in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mtek
 
Posts: n/a

Default Submitting Forms - 05-31-2008 , 06:46 PM







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

Reply With Quote
  #2  
Old   
Dan Rumney
 
Posts: n/a

Default Re: Submitting Forms - 06-01-2008 , 08:48 PM






Quote:
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?
submit() is a method on a form object... you can't just call it on its own

If you provide some sample code which demonstrates the problem that
you're having, that would be helpful.

Thanks


Reply With Quote
  #3  
Old   
Bart Van der Donck
 
Posts: n/a

Default Re: Submitting Forms - 06-02-2008 , 09:50 AM



Rumney wrote:

Quote:
??? 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.