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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.