|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Moving to next tabindex on event
Ok,...I am trying to setup a script that will move my cursor to the next tabindex for a form field when the length of a string hits a certain length.
In other words, for my area code field. When the length hits 3, I want the cursor to move to the prefix phone number field. I have the js code to check the length of the field. I am just not sure what "On" event to use in the form field tag itself. Any Ideas?
__________________
-- Jason |
|
#2
|
||||
|
||||
|
Once you hit your field limit, the next line of your javascript should be;
"document.frmName.txtPhoneNumber.focus()" Not sure about automatically jumping to the next tabIndex - i think u'll have to hardcode it. Last edited by stumpy : February 11th, 2003 at 04:27 AM. |
|
#3
|
|||
|
|||
|
Jump to next control with JavaScript
Quote:
Here some code to get you going ;-) <script> function OnKeyPress(field, event) { if (event.keyCode == 13) { for (i = 0; i < field.form.elements.length; i++) if (field.form.elements[i].tabIndex == field.tabIndex+1) { field.form.elements[i].focus(); if (field.form.elements[i].type == "text") field.form.elements[i].select(); break; } return false; } return true; } </script> AND this is your control: <input type="text" name="Name" tabindex="2" onKeyPress="return OnKeyPress(this, event)" /> |
|
#4
|
|||
|
|||
|
Hey all...
Look, the easiest way to aproach is this Code:
<script...>
function moveto(obj1, chars, obj2){
if(obj1.value.length == chars)
obj2.focus();
}
</script>
<html>
........
........
<form name="ff" .....>
<input type="text" name="text1" onKeypress="moveto(this, 3, document.ff.text2);">
<input type="text" name="text2">
</form>
........
........
</html>
Good Luck.... Anibal. |
|
#5
|
||||
|
||||
|
Wow - this is an OLD thread - over 2 years old!
|
|
#6
|
|||
|
|||
|
Right!!! I haven't noticed that.....Damn, are we getting old or what!!
Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Moving to next tabindex on event |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|