Solved

SSN SHIFT+TAB Problem

Posted on 2006-07-03
1
884 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
1 Comment
 
LVL 15

Accepted Solution

by:
bpmurray earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 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