Fires when a FORM is about to be submitted.
VARIANT_BOOL onsubmit( IHTMLEventObj *pEvtObj );
If the event bubbles and is cancellable, return VARIANT_TRUE to prevent the event from bubbling to other event handlers in the document tree. Return VARIANT_FALSE to allow bubbling.
The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
Bubbles No Cancels Yes To invoke Submit a form using the INPUT TYPE=submit, INPUT TYPE=image, or BUTTON TYPE=submit object. Default action Causes a form to be sent to whatever location is stipulated in the ACTION attribute of the form object.
Event Object Properties
The IHTMLEventObj interface contains additional information about the current event. When the onsubmit event is fired, you can use the IHTMLWindow2::event property to retrieve an IHTMLEventObj interface. To obtain an alternate interface pointer such as IHTMLEventObj2 or IHTMLEventObj3, call QueryInterface on the object.
IHTMLEventObj::altKey Gets a value that indicates the state of the ALT key. IHTMLEventObj2::altKey Gets a value that indicates the state of the ALT key. IHTMLEventObj3::altLeft Gets a value that indicates the state of the left ALT key. IHTMLEventObj::ctrlKey Gets the state of the CTRL key. IHTMLEventObj2::ctrlKey Gets or sets the state of the CTRL key. IHTMLEventObj3::ctrlLeft Sets or retrieves the state of the left CTRL key. IHTMLEventObj::returnValue Sets or retrieves the return value from the event. IHTMLEventObj::shiftKey Gets the state of the SHIFT key. IHTMLEventObj2::shiftKey Gets the state of the SHIFT key. IHTMLEventObj3::shiftLeft Retrieves the state of the left SHIFT key. IHTMLEventObj::srcElement Gets the object that fired the event. IHTMLEventObj2::srcElement Gets or sets the object that fired the event. IHTMLEventObj::type Gets the event name from the event object. IHTMLEventObj2::type Gets or sets the event name from the event object.
Refer to the specific event object for additional event properties.
You can override this event by returning
falsein the event handler. Use this capability to validate data on the client side to prevent invalid data from being submitted to the server. If the event handler is called by the HTMLFormElementEvents2::onsubmit attribute of the form object, the code must explicitly request the return value using the return function, and the event handler must provide an explicit return value for each possible code path in the event handler function.
The IHTMLFormElement::submit method does not invoke the HTMLFormElementEvents2::onsubmit event handler.