Solved

SSN SHIFT+TAB Problem

Posted on 2006-07-03
1
878 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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is about my first experience with programming Arduino.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now