How to do Auto Jumb between text boxes in JavaScript ?
Given example baptize you clearly how to implement jump from one text box to another automatically when one gets filled.
Here i have 3 text boxes and plannig to get 3,2,3 charecters in textbox1,2,3 respectivley from the user. It is the best way to do validation and navigating/jumping to the next boxes automatically when the boxes filled.
In this following form user can enter 3 charecters in first box and it will jump to second box automatically when first box filled with 3 chareccters.
Same way 2 box will expect 2 charecters from the user and it will jump to third when 2nd box filled with two charecters.
You can use the given exaple code, Wherever you need the user to jump automatically between text boxes. For example, forms getting license key,bank account number,date of birth,ticket number,railway reservation,Family card number,PAN number,Passport number,Purchase order number etc.,
File : AutoJump_JS.html
<html>
<head>
<script type="text/javascript">
function checkLen(x,y)
{
if (y.length==x.maxLength)
{
var next=x.tabIndex;
if (next<document.getElementById("myForm").length)
{
document.getElementById("myForm").elements[next].focus();
} }}
</script>
</head>
<body>
<p>This script automatically jumps to the next field when a field's maxlength has been reached:</p>
<form id="myForm">
<input size="3" tabindex="1" maxlength="3" onkeyup="checkLen(this,this.value)">
<input size="2" tabindex="2" maxlength="2" onkeyup="checkLen(this,this.value)">
<input size="3" tabindex="3" maxlength="3" onkeyup="checkLen(this,this.value)">
</form>
</body>
</html>
==================================================================================================================================
==================================================================================================================================
Jan 23, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Saalram.com