Jump to content

[SOLVED] automatic tab after finish filling an input field


ted_chou12

Recommended Posts

Hi, for example like a phone number field, if you set the first input field to max of 3, and after finish filling the three, the auto tab proceeds on to filling the rest of the phone number so you don't have to press tab or use mouse to click, is that possible? and how do you do it?

Thanks,

Ted

by using some java script you can easily achieve this goad.

 

<input type="text"  onkeyup="SetTelephoneFocus(this,1,1);"  id="txtBusinessPhone11" maxlength="3" name="txtBusinessPhone11" />

<input type="text" onkeyup="SetTelephoneFocus(this,1,2);"id="txtBusinessPhone21" maxlength="3" name="txtBusinessPhone21" />

<input type="text"  id="txtBusinessPhone31" maxlength="4" name="txtBusinessPhone31"/>

<script type="text/javascript">

function SetTelephoneFocus(otype, location, position)

{

var slen = otype.value;

if(slen.length ==3)

  if (position==1)

{

  //set to snd postion

  document.getElementById("txtBusinessPhone2"+location).focus(); 

}

else if (position==2)

{

//set to third position

document.getElementById("txtBusinessPhone3"+location).focus();

}

}

}

</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.