user1638055
user1638055

Reputation: 492

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!

Upvotes: 1

Views: 2457

Answers (1)

James Allardice
James Allardice

Reputation: 165971

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.

Upvotes: 3

Related Questions