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.

Window.Blur

Example Code Below:

1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

2 <html xmlns="http://www.w3.org/1999/xhtml">

3 <head>

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

5

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

7 function ValidateName() {

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

9 }

10

11 </script>

12

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