how to make the enter key do the tab key function
When I move in form field I want with 'enter' key move into next field not with 'tab' key this mean I need to build html code which every time user press enter key on a input text tag, following input box must be focused.
2 Answers
Using jQuery:
$(document).ready(function () { $(":input).keypress(function(event) { if (event.keyCode === 13 || event.keyCode === 10) // 10 is for mac event.preventDefault(); $(this).next(":input").focus(); } }) });This may work if all of your input types are at the same level (siblings). Otherwise you may need to cache off the $(":input) array and loop through that manually. Posted: Go 1 of 1 people found this answer helpful. Did you? Yes No
Please don\'t do that. It will make users hate your form, The worst thing you can do for a user friendly form is breaking the way forms usually work. Altough, if you really want to do it, you have to use a hander on each input for the enter key (key id is 13) and then focuses the next input using the focus() function. That post might help you
and You are breaking a well established UI/UX principle. It just like making your right mouse button behave like the left one. and the left like the right. Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No Hi,why user will hate my form,it that function make move into next filed with enter because you will breaking the way forms usually work |
© Advanced Web Core. All rights reserved