Solved

jQuery Form Controls

Posted on 2013-01-31
3
255 Views
Last Modified: 2013-02-01
Hey guys

I need some help with a form that I'm trying to create, with some jQuery controls in place.

The form is laid out in a table gird, with a mixture of <input> and <select> fields.

Some of the <input>'s are using jQuery UI autocomplete, others don't.

I have added arrow key navigation to the sheet, so that users can use the up, down, left, right keys to move to different cells (which is turned off when the autocomplete list is open to let people move up and down in the dropdown list).

The controls that I would like to add are:

1) Enter key - From a data entry stand point, I find the enter key a good way to traverse the different fields in the form.  I would like to have this functionality, without the form submission tied to the enter key (without breaking autocomplete).

2) Form select - Since we are hopefully removing form submission from the enter key, I would like to have a button and/or keyboard combination that submits the form (preferable both, with the obvious choice for the key combo of CTRL-S

Can you please help me.

Thanks
0
Comment
Question by:srfreemaninc
3 Comments
 
LVL 51

Assisted Solution

by:Julian Hansen
Julian Hansen earned 250 total points
ID: 38840433
You will have to capture the keypress event and then check to see what control the event was triggered from. Set a flag if the submit button / control was the origin of the event.

Use a submit handler to trap the submit - if the flag is not set then don't allow the submit to continue (return false / event.preventDefault)
0
 
LVL 11

Accepted Solution

by:
mcnute earned 250 total points
ID: 38840541
You can trigger the enter press by this line of jquery:

$.trigger({ type: 'keypress', which: keycode });

Open in new window


Here are a list of keycodes: http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
0
 

Author Closing Comment

by:srfreemaninc
ID: 38845608
Thanks guys for the help.  Got something working, still need to tweak a few things.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now