Form.onsubmit() HandlerNameForm.onsubmit() Handler---invoked when a form is submittedSynopsis
<FORM onSubmit="handler-statements" a definition of the handler ...attributes... other attributes here > form.onsubmit a reference to the handler form.onsubmit(); an explicit invocation of the handler Descriptiononsubmit() is an event handler which is invoked when the form it is associated with is submitted, either when the user clicks a Submit button object, or when the submit() method is called for the form. This event handler is defined by the onSubmit attribute of the <FORM> tag that defines a form. The value of the attribute may be any number of JavaScript statements, separated by semicolons; these statements will be executed when the form is submitted. A typical use of the onsubmit() event handler is to check that the user's input is valid before sending it over the network to a server. If the data is not valid, the onsubmit() handler may cancel form submission by returning the value false. If the handler returns any other value, or returns no value at all then the form will be submitted normally. UsageWhenever you use the onsubmit() event handler to cancel the submission of a form, you should be sure to notify the user why the submission was canceled, so that they can correct the problem. Window.alert() is a useful way to provide this information to the user. |
|