How do I execute my function whenever the input field loses its focus?

Viewed 30

In Javascript, I want to execute my function whenever the textbox loses its focus. What's the easiest way to do this?

2 Answers

In most of the case I don't use onblur I use onchange method because it will indicate user only if user change the value of text box so i think it's user friendly.

Easiest method is to add your javascript in html tag

   <input type = "text" onchange = "yourFunction()">

but this is not a good practice. Write your javascript in external file.

Related