![]() ConclusionĬonverting your Enter key press into another key press, such as Tab, is a rather crude workaround to a common problem of early form submission, but it’s a starting point to alleviating issues your end users may run into. Note: Since we are converting to a Tab key press, you’ll want to make sure the TabIndex of your controls is set appropriately so user’s are progressed in the desired order down/across the page. If the key press is Enter, the function will return a Tab key press which moves focus to the next control in TabIndex order. ![]() In the above example, any time a user has focus on the Textbox and presses a key our JavaScript function will be called. ( "onKeyDown", "ModifyEnterKeyPressAsTab() ") Below are two examples, first on an HTML or ASPX page (includes tag) and second in an external file (without tag.) Since my current work is on SharePoint development I place most of my JavaScript functions into an external file ( previous blog post details) to be referenced by web part code. Please read these references for more information on cross-browser compatibility.įirst, you’ll need to add a JavaScript function to trap the Enter key press (ke圜ode 13) and convert it to a Tab key press (ke圜ode 9). I wish I could claim the credit for this, but I found this on many online resources ( reference 1 and reference 2.) Note: My example focuses on Internet Explorer I have not tested against other browsers at this time. Tab key.) A few simple lines of JavaScript and adding a client-side event handler to your input controls can accomplish that. If you are looking for a quick (partial) fix though, it is possible to trap the Enter key press and convert it to another key press (e.g. The most complete solution to this issue is having your submit process be able to handle all scenarios of submission (incomplete, invalid, etc). ![]() How many times have you been filling out an online form and halfway through filling in your responses you accidentally press the Enter key which then attempts to submit the form? This can be a common problem when the online form is wired up to have a “submit” button be the default form button on a page.
0 Comments
Leave a Reply. |