This function cancels an event and prevents it from bubbling up.
Parameters:
- event – reference to the event to cancel
Example:
In this example, we prevent the onclick event if other fields on the screen are not validated properly.
Note: We assume that validated() is a custom-built function that is available for use. We also assume that validated() returns true or false to indicate the validity of certain fields on the screen.
var submitButton = getObj("my_button"); submitButton.onclick = function(event) { if(!validated()) //if fields on the screen are not valid { preventEvent(event); } }