0

Sir/Madam I have create a web site that site has many pages and pages are many controls. for example i have 12 controls 3 textboxes 2 dropdownlistbox1 2 chkbox 2 radiobutton 1 button .. user wants when he press enter key focus will be to the next control .. i found some googly but they move on textboxs not on any other control using Jquery....

AnonJr
  • 2,759
  • 1
  • 26
  • 39
Md Nawaz
  • 71
  • 1
  • 10
  • Provide code, and examples please. – RogueSpear00 Oct 09 '13 at 04:48
  • I believe the correct response to a request like this from a client is, "No". The enter submit forms, tab switches focus. If they're resistant, simply put some tape on his keyboard's tab key and write "enter" on it. – DACrosby Oct 09 '13 at 05:30

4 Answers4

2

I believe you are looking for something like this

$(document).keypress(function(e) {
if(e.which == 13) {
$(document.activeElement).next().focus();
}
});

Demo Fiddle

0

You might want to go through this

How do I convert Enter to Tab (with focus change) in IE9? It worked in IE8

Although my advice is that never use enter as tab because pressing enter causes the form to submit, and you will have to prevent that in order to use it as tab.

Community
  • 1
  • 1
progrAmmar
  • 2,606
  • 4
  • 29
  • 58
0

use the jquery selector to find all your controls, for example if your controls are of type Input: $('input').on('keypress', function(){})

see jQuery Event Keypress: Which key was pressed?

http://api.jquery.com/keypress/

I recommend using the jquery ".on" function instead of the ".keypress" function

Community
  • 1
  • 1
0

if there are two text boxes textbox1 and textbox2 respectively. just put all in update panel and enable autopostback for all controls.and then write the following code in the textchanged of textbox1 ,

textbox2.focus();

then the focus will goto the textbox2 after entering in textbox1.

make sure that the autopostback property is on for all controls that u want to get focus.

jyothis
  • 84
  • 1
  • 3
  • 8