Solved

Automatic go to textbox2 when a user gives an enter in textbox1.

Posted on 2011-09-07
4
518 Views
Last Modified: 2013-12-17
Hi,

I have 2 textboxes on my form, one is called textBox1 and the other is
called textBox2. I would like when a user is typing in textBox1 and presses
the enter-key it goes automaticly to textBox2.

How can I go from textBox1 to textBox2 after pressing the enter-key?

Who can help me and know the answer?

Greetings,

Peter Kiers
0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Praveen_Bobbili earned 500 total points
ID: 36494372
Hi,
Give the onkeypress event to textbox1

<input type="text" id="textbox1" onkeypress="optionkeypress(eve);"/>
function optionkeyress(evt)
{
     if(evt.keycode == 13)
       {
txtbox2.focus();
}
 
}
 
 
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36494400
I don't know if it's me but I don't know what I am doing wrong, but i get errors:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (keycode == 13)
            {
                textBox2.focus();
            }
        }

Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36494441
Gotit:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                textBox2.Focus();

            }
        }

Greetings,

Peter Kiers
0
 
LVL 1

Expert Comment

by:Praveen_Bobbili
ID: 36494854
May be somewhere you got the conflict with other javascript. Try to do with error console in firefox.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question