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:
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:
No comments:
Post a Comment