Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with submit() and onSubmit...

Status
Not open for further replies.

Boblevien

Technical User
Nov 3, 2000
38
GB
I have a JavaScript function [checkForm(n)] which checks that the first “n” fields of a form are not blank - gets called when the form is submitted:

<form action=&quot;cdonts/premail.asp&quot; method=&quot;post&quot; id=&quot;form1&quot; name=&quot;form1&quot; language=&quot;javascript&quot; onSubmit=&quot;return checkForm(2)&quot;>

But I find those Submit buttons a bit ugly so I want to use:

<A href=&quot;javascript:document.form1.submit();&quot;>post message<br></A>

It submits OK but it doesn’t trigger the checkForm(n) – doesn’t seem to be the same submit.

Can anyone suggest a work around?

Bob.

 
Just write a function which does all your validation, then calls submit() at the end - and call this function from your link.
b[sup]2[/sup] - benbiddington@surf4nix.com
 
Also, in the code &quot;<A href=&quot;javascript:document.form1.submit();&quot;>post message<br></A>&quot; there shouldn't be a &quot;;&quot; after the link href. If you want to use an image to submit then do this:

<input type=&quot;image&quot; src=&quot;image-location.gif&quot;>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top