Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7866591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:26:40+00:00 2026-06-03T00:26:40+00:00

I have three Textboxes for Phones numbers. Textbox1 max length is 3 , 2nd’s

  • 0

I have three Textboxes for Phones numbers. Textbox1 max length is 3 , 2nd's max length is 3 and 3rd max length is 4. When user types three digits in TextBox1 the cursor moves automatically to TextBox2 same thing happens with TextBox2 as well as TextBox3. I am handling this functionality in keyup event.

enter image description here

Issue is, when I press

Ctl + a

Ctl + c

Ctl + v

the cursor moves automatically to Textbox3 because Textbox reaches it’s Max Length and navigates it to next Textbox. I want to keep it on TextBox1. Any Ideas?

My code is below.

<asp:TextBox runat="server" ID="tbPh2" MaxLength="3" onkeyup="Mainautotab2(this, 0, event);"/>
<asp:TextBox runat="server" ID="tbPh22" MaxLength="3" onkeyup="Mainautotab2(this, 1, event);"/>
<asp:TextBox runat="server" ID="tbPh222" class="midium" MaxLength="4" />


function Mainautotab2(original, destination, evt) {
         if (document.getElementById('<%= tbPh2.ClientID%>').value.length == 3 && document.getElementById('<%= tbPh22.ClientID%>').value.length == 3) {

         if (destination == 0)
             document.getElementById("<%=tbPh22.ClientID %>").focus();
         if (destination == 1)
             document.getElementById("<%=tbPh222.ClientID %>").focus();
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:26:41+00:00Added an answer on June 3, 2026 at 12:26 am

    I would recommend checking for the use of the control key being pressed, see this post for more information on how to do that. If you detect the CTRL key is pressed then do not move to the next textbox.

    Alternatively, if you only want the “move to next” feature to work as the user is typing the 3rd character then perhaps something along the lines of checking the character count on keydown. Make sure that this new key press in the 3rd character and the previous keypress was the second character (i.e. store lastKeyPressCount somewhere)


    As I am such a nice guy! here is some of my own work:

    Html

    <input type="text" id="1" maxlength="3" data-nextid="2"/>
    <input type="text" id="2" maxlength="3" data-nextid="3"/>
    <input type="text" id="3" maxlength="4"/>​
    

    JavaScript (w/JQuery)

    $("input").keyup(function(e){
        if(e.ctrlKey || e.which == 17 || e.which == 65 || e.which == 67 || e.which == 86){
            return;        
        }
        if($(this).val().length == $(this).attr("maxlength")){
            var nextid = $(this).data("nextid");
            if(nextid){
                  $("#" + nextid).focus();       
            }
        }
    });​
    

    Keep in mind that this code has been specifically set to ignore the CTRL key in addition to the letters A, C and V.

    See here for a working example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets just say that I have three textboxes: TextBox1, TextBox2, TextBox3. Normally if I
I have three textboxes in my control,for hour, minute and second. User can input
If i have three textboxes in my vb.net webform .. Textbox1.text=Sumit Textbox2.text=4-Dec-2010 Textbox3.text=1-Jan-2011 I
I have taken three textboxes over aspx page. A JavaScript function is associated with
Have three classes User, Group and Field. Many to many relationship on User /
this is a CSS / design question. I have three textboxes that i want
I have three textboxes and I want to validate them. At least one textbox
I want to have three textboxes(only one of them will be shown to input
In a Windows Phone project I have the following scenario: The user types some
I have a UserControl that consists of three TextBoxes. On a form I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.