Solved

SSN SHIFT+TAB Problem

Posted on 2006-07-03
1
881 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 75
firstChar challenge 13 110
How to remove numeric and alpha from an alphanumeric field? 5 73
Is doing tutor.com teaching in my situation advisable? 2 57
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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 …
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…

867 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

18 Experts available now in Live!

Get 1:1 Help Now