Tuesday, July 9, 2019

Blur event in JavaScript

Onblur event will be fired when control lose the focus.
Example:
Place the curosr in the below texboxes one after one.

Code Sample:

<html>
<head>
    <title>Onblur event example in JavaScript</title>
    <script language="Javascript">
        var cnt = 0;
        var arybg = new Array("Red", "Green", "Blue", "Yellow", "Black", "Brown"); 

        function onblurevt(evt, t) {
            if (cnt == arybg.length)
                cnt = 0;
            t.style.backgroundColor = arybg[cnt];
            cnt++;
        } 

    </script>
</head>
<body>
    <table align="center">
        <tr>
            <td>
                Place the curosr in the below texboxes one after one.
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="Text1" onblur="onblurevt(event,this);" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="Text2" onblur="onblurevt(event,this);" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="Text3" onblur="onblurevt(event,this);" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="Text4" onblur="onblurevt(event,this);" />
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" id="Text5" onblur="onblurevt(event,this);" />
            </td>
        </tr>
    </table>
</body>
</html>

No comments:

Post a Comment

Lab 09: Publish and subscribe to Event Grid events

  Microsoft Azure user interface Given the dynamic nature of Microsoft cloud tools, you might experience Azure UI changes that occur after t...