Solved

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

Posted on 2011-09-07
4
515 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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