View Single Post
Old 02-13-2013, 02:49 AM   PM User | #1
durangod
Senior Coder

 
Join Date: Nov 2010
Posts: 1,177
Thanks: 214
Thanked 31 Times in 30 Posts
durangod is on a distinguished road
moving focus on maxlength

Hi i have this working but i have some quesitons.

First is this up to current standards.
Second what is the standard action when you get to the end of this group.
a. leave it on the last input focus for this group
b. focus back on the first input in case they want to start over.
c. move to the next input after this group and stop.


i am seperating the ip input into 4 sections. I will tie then together later.

Code:
//js

function moveMax(pfield,nfield)
{
  if(pfield.value.length >= pfield.maxLength)
   {
    document.getElementById(nfield).focus();
   }//close if
}//end function moveMax



//inputs

<input type="text" name="domainIPa" id="domainIPa" value="" size="2" maxlength="3" onkeyup="moveMax(this,'domainIPb');" /> -
<input type="text" name="domainIPb" id="domainIPb" value="" size="2" maxlength="3" onkeyup="moveMax(this,'domainIPc');" /> -
<input type="text" name="domainIPc" id="domainIPc" value="" size="2" maxlength="3" onkeyup="moveMax(this,'domainIPd');" /> -
<input type="text" name="domainIPd" id="domainIPd" value="" size="2" maxlength="3" onkeyup="moveMax(this,'domainIPa');" />

Thanks
durangod is offline   Reply With Quote