In Association with Amazon.in   Flipkart

Tuesday, November 19, 2013

JavaScript OnKeyUp/OnKeyDown/OnKeyPress Event Example

JavaScript OnKeyUp/OnKeyDown/OnKeyPress Event: When we hit each key in keyboard a function called.

 Example:

<!-- OnKeyUp & onKeyPress & OnKeyDown -->
<html>
<head>
</head>
<body>
<form>
Enter Key: <input type="text" name="field1" id="f1" size="5"
onkeyup="if(this.value.length>=4)
document.getElementById('f2').focus();" /> -
<input type="text" name="field2" id="f2" size="5"
onkeyup="if(this.value.length>=4)
document.getElementById('f3').focus();" /> -
<input type="text" name="field3" id="f3" maxlength="4" size="5"/>
</form>
</body>
</html>


Output:

Enter Key: - -

No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...