How to use the Javascript Windows.Blur object or using the OnBlur event.

When an object has lost its focus, an onBlur event is raised. You could also raise this event manual by call the windows objects.


Example Code Below:

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

2 <html xmlns="">

3 <head>

4 <title>Javascript: How to use blur event</title>


6 <script type="text/javascript" language="JavaScript">

7 function ValidateName() {

8 alert("You are raising a blur event")

9 }


11 </script>


13 </head>

14 <body>

15 Please enter your name.<br />

16 <br />

17 Name:

18 <input value="" type="text" name="name" onblur="ValidateName()">

19 </body>

20 </html>


The blur event has two property of Type and Target.

You would use this event to validate an input when the user would try to move on to the next text field.



* iOS Development * OS X * Product Review