views:

1380

answers:

4

I have a standard HTML input that I want to run JavaScript code when it loses focus, sadly my Google searches did not reveal how to do this.

To make it clear, I'm looking for a way to do this:

<input type="text" name="name" value="value" onlosefocus="alert(1);"/>
+11  A: 

How about onblur event :

<input type="text" name="name" value="value" onblur="alert(1);"/>
Canavar
Yep, that's how you'd do it.
KyleFarris
What's with the obtrusivness???
J-P
+4  A: 

You want to use the onblur event.

<input type="text" name="name" value="value" onblur="alert(1);"/>
Daniel Lew
+2  A: 

I think you're looking for the onBlur event. Look here, for more details.

Loïc Wolff
+3  A: 

onblur is the opposite of onfocus.

Gumbo