Universal Related Popup Menus / Conditional Submit | WebReference

Universal Related Popup Menus / Conditional Submit

Conditional Submit

Universal Related Popup Menus

In order to meet our goal of universality we had to find a way to make a dual function submit button. We knew we needed to call a redirect CGI script with a matching submit button for non-JavaScript enabled browsers, but how could we prevent JavaScript-enabled browsers from calling this script?

JavaScript: The Definitive Guide says that the onClick event handler can not stop a submission for Netscape 2:

The Submit button has the special function of submitting a form to the server. This event handler may add any additional functionality to the Submit button. In Navigator 2.0, there is no way for this onClick() event handler to cancel the submit action or to prevent the form from being submitted; use the Form.onsubmit() event handler to prevent input validation and to cancel form submission if necessary.

In Navigator 3.0, the onClick() event handler may return false to prevent the Submit object from submitting the form. - page 536

The way to cancel a submit button is through the onSubmit() event handler.

...if the data is not valid, the onsubmit() handler may cancel form submission by returning the value false. - page 410.