Copyright ©

Prototype Event stop() Method

previous next


This method stops the event's propagation and prevents its default action from being triggered eventually.

There are two aspects to how your browser handles an event once it fires up:

Because stopping one of those aspects means, in 99.9% of the cases, preventing the other one as well, Prototype bundles both in this stop function. Calling it on an event object stop propagation and prevents the default behavior.



Return Value :


Here's a code snippet that prevents a form from being sent to the server side if a certain field is empty.

Event.observe('signinForm', 'submit', function(event) {
  var login = $F('login').strip();
  if ('' == login) {
    // Display the issue one way or another

previous next

Copyright ©