Click to See Complete Forum and Search --> : Combining OnSubmit with POST


peterhar
07-09-2003, 04:46 PM
I'm trying to understand some HTML and am stuck on the following line:

<form name="sendtextform" action="/webOriginate/action/sendMessage" onSubmit="return validate()" method="post">

The JavaScript validate() function returns either true or false.

What I don't get is what happens on submit. Is the validate function called followed by the post, or do they happen together? Is there some dependency between them?

Thanks for all comments.

pyro
07-09-2003, 05:07 PM
What will happen when you submit is this: It will run the function named validate, and return either true or false. If it returns true, it will submit your form, if it returns false, it will not submit your form.

Charles
07-09-2003, 05:07 PM
When a "submit" button is called (<input type="submit"> or <button type="submit">some text</button>) the "onsubmit" handler is called and then, unless the handler returns "false", the form is submitted to the address specified by the form's "action" attribute. Note however, that the form also has a "submit" method that submits the form directly, bypassing the "onsubmit" handler.