For standard HTML attribute information about the <FORM>
element, see the <FORM>
topic.
The <FORM>
element supports two scripting events, both of which can also be scripted elsewhere.
OnSubmit
This event can be used to execute some script code when the form is submitted. For example, you may want to check whether all the necessary boxes/radio options etc., have been filled out satisfactorily, before sending the script information to the server-side script that acts on the form data. For example :
<FORM NAME="survey" ACTION="/cgi-bin/survey.cgi" METHOD="POST" OnSubmit="return check_data()">
. . . [other form elements]
</FORM>
NOTE : The return
keyword is necessary if the script is checking the data and requires blocking of the form data transmission if the script code returns false (i.e. if the validation fails, because an element hasn't been filled out properly). Using it as above, the form data will only be transmitted back to the server, if the validation script is satisfied that enough data has been entered.
OnReset
The OnReset
event handler is used to execute a script function if the user resets the form (by pressing the 'Reset' button if it is available).
NOTE : As said before, both of these two events can be handled elsewhere, by using the OnClick
event of the form Submit and Reset buttons (<INPUT TYPE="Submit" OnClick="script">
and <INPUT TYPE="Reset" OnClick="script">
respectively) See the <INPUT>
topic for more information.