Search code examples
prototypejsobservers

Prototype: Whats the event for losing focus?


I want to make some changes to a text field once it loses the focus but I cant figure out the event I need. This is my code:

Event.observe('my_text_field', '????', function(event) {
    do something here
}

So, what do I have to put in instead of the ???? ?

Thanks!


Solution

  • You are looking for the blur event:

    The blur event is fired when an element has lost focus.

    And from the DOM2 Events spec:

    The blur event occurs when an element loses focus either via the pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.