|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is it possible to force the curser into the next text box once the preceeding one has reached maxlength? If so how......
in need to input a string broken into 6 sets of 2 characters....ie 55:66:77:88:99:00... when the data is filled in i want the input to fluidly jump to the next text box.. thanks |
|
#2
|
|||
|
|||
|
Hi. I wasn't sure what the best event would be for calling the function that will move focus (I used onkeypress, but I don't think NS has that event). I don't know if this will help you, but as an alternative you could just use one text box, and let the user enter the characters as a string. Then you could call the function "SPLITM()" which just creates a character array out of your string. Then it pairs off the characters and you could format them however you want or just leave them as elements in the array.
Here you go: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><html> <head> <script language="JavaScript"><!-- function MOVEIT(i) { if (document.forms[0].elements[i-1].value.length >1) { document.forms[0].elements[i].focus() } } function SPLITM() { var STRING = document.forms[1].elements[0].value; var TEST=STRING.split("") //if you call the split method with the empty string as an argument it will return a character array. alert(TEST[0]+TEST[1]+":"+TEST[2]+TEST[3]+":"+TEST[4]+TEST[5]) // then you could just pair off the array elements. } //--></script> </head> <body> <form> <table> <tr> <td><input type=text onkeypress=MOVEIT(1)></td> <td><input type=text onkeypress=MOVEIT(2)></td> <td><input type=text onkeypress=MOVEIT(3)></td> <td><input type=text onkeypress=MOVEIT(4)></td> <td><input type=text onkeypress=MOVEIT(5)></td> <td><input type=text onkeypress=MOVEIT(6)></td> <tr><td><input type=submit value="all done"></td></tr> </tr> </table> </form> <form><table><tr><td><input type=text></td></tr></table><input type=button value="SPLITM()" onclick=SPLITM()></form> </body> </html>[/code] |
|
#3
|
|||
|
|||
|
Thanks for the reply...but thats not what I need....i do combine the fields once inside of my perl script.
The fields are broken up to avoid invalid characters being entered when creating new DNS Hardware Address entries (hence the 55:66:77:88:99:00). I just want a fancy form that progresses to the next text box. Thanks again.... |
|
#4
|
|||
|
|||
|
Uhh, that first function "MOVEIT()" changes focus to the next text box when the length of the value in the one preceding it exceeds 2 digits. That's not it? You could also use some high tech RegEx on your web page to validate entries. JS 1.2 supports RegEx well.
|
|
#5
|
|||
|
|||
|
Sorry, now that I've tried the code by itself it works......only problem is whenever I move the code into my existing page it returns the following:
Error: 'document.forms.0.elements[...].value' is not an object This error pops up when entering any character into the input boxes with the MOVEIT() attached ???????? Thanks [This message has been edited by deviant (edited July 21, 2000).] |
|
#6
|
|||
|
|||
|
OK....works great now.....increased the form from 0 to 1 because I had 2 forms on the page.....thanks for everything
|
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Advancing Text box......possible? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|