Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SSN SHIFT+TAB Problem

Posted on 2006-07-03
1
Medium Priority
?
905 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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 …
Starting up a Project

604 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