Re: onSubmit and submit()

by "Arcady"<arcady(at)jps.net>

 Date:  Thu, 11 May 2000 21:39:02 GMT
 To:  hwg-techniques(at)mail.hwg.org
  todo: View Thread, Original
onSubmit happens 'after' the browser has sent off the submission. So it's useless
for prechecking submitted items. It can be used to do something as or after
you submit though.

generally you want one of these:

<a href="x" onclick="document.formname.submit();return false;"><img src="submitbutton.gif"></a>

or
<input type="button" name="submitbutton" value="Click to send" onclick="document.formname.submit();return
false;">

Or if you desire to precheck it:

<a href="x" onclick="submitcheck();return false;"><img src="submitbutton.gif"></a>

or
<input type="button" name="submitbutton" value="Click to send" onclick="submitcheck();return
false;">

and inside you <head></head> tags:

<script>
function submitcheck(){
 if(stuff == true) {
   document.formname.submit();
 } else {
   alert("Hey blockhead, that wasn't the right way to fill out a form. :)");

 }
}
</script>




>> Is it possible that the combination doesn't work?
>> I have tried to use onClick="document.form.submit()" and to use the
>> onSubmit on the FORM statement to do some checking.  As far as I can
>> see onSubmit is then not invoked.
>>
>> Tia, Albert
>>
>>
>
>
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA