rodrigosantosbr

[JS] Autotab

Jan 17th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

http://jsbin.com/?html,js,output


HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<b>Enter your 10-digit phone number:</b>
<form name="sampleform" method="post">
<input type="text" name="first" size=4 onKeyup="autotab(this, document.sampleform.second)" maxlength=3> <input type="text" name="second" size=4 onKeyup="autotab(this, document.sampleform.third)" maxlength=3> <input type="text" name="third" size=5 maxlength=4>
</form>
</body>
</html>

Javascript

function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

Add Comment
Please, Sign In to add comment