?
Solved

SSN SHIFT+TAB Problem

Posted on 2006-07-03
1
Medium Priority
?
898 Views
Last Modified: 2012-06-27
Hi,

I am using this javascript code for auto tab in my SSN


<body>
<form name=blahForm>
Enter your SSN:<br>
<input type=text name=first size=3 maxlength=3 onkeyup='if (this.value.length == 3) {blahForm.middle.focus();blahForm.middle.select()}'>-
<input type=text name=middle size=2 maxlength=2 onkeyup='if (this.value.length == 2) {blahForm.last.focus();blahForm.last.select()}'>-
<input type=text name=last size=4 maxlength=4>
</form>
</body>
</html>

Problem
--------
while I want to change the value in SSN by clicking  SHIFT+TAB it again go to next part

Thanks
0
Comment
Question by:SystemExpert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
bpmurray earned 2000 total points
ID: 17030922
You can so something like this:
<html><head>
<script type="text/javascript">
function doKeyup(elem, evt) {
   var Fld = elem;
   if (evt.shiftKey && evt.which == 9) {
      Fld = elem.previousSibling.previousSibling;
   } else if (elem.size <= elem.value.length) {
       Fld = elem.nextSibling.nextSibling;
   }
   Fld.focus();
   Fld.select();
}
</script>
<body>
<form name=blahForm>
Enter your SSN:<br>
<input type="text" name="first" size="3" maxlength="3" onkeyup="doKeyup(this, event);">-
<input type="text" name="middle" size="2" maxlength="2" onkeyup="doKeyup(this, event);">-
<input type="text" name="last" size="4" maxlength="4">
</form>
</body>
</html>

But that's way too complicated for what you need. Simply set tabindex="1", "2" and "3" on the three fields, and the tab and shift-tab will work as you expect.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question