prevent submit onEnter for one element

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
sgagn0
Profound User
Posts: 41
Joined: Fri Aug 16, 2013 7:23 am
First Name: Sebastien
Last Name: Gagne
Company Name: Oceanex
Contact:

prevent submit onEnter for one element

Post by sgagn0 »

Hi,

Is there a way we can prevent the enter key to submit the page for a specific element in the page?
When cursor is position in a textbox (lets say Client#) and the user press enter, I would want to load the client name in javascript. On any other element, I would want to submit to the server on enter.

Thanks,
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: prevent submit onEnter for one element

Post by Scott Klement »

Have you tried calling preventEvent() in the onkeydown event when the enter key is pressed? That's the first thing I would try... when enter is presssed, do whatever JavaScript you want to do, and call preventEvent() to prevent the default enter key behavior.

preventEvent() is documented here:
http://www.profoundlogic.com/docs/displ ... +event+%29
sgagn0
Profound User
Posts: 41
Joined: Fri Aug 16, 2013 7:23 am
First Name: Sebastien
Last Name: Gagne
Company Name: Oceanex
Contact:

Re: prevent submit onEnter for one element

Post by sgagn0 »

I should have mention that the field is added in javascript. Therefore, I do not have access to the onkeydown event of profound.
I tried to add the preventEvent in the JQuery keydown event, but it looks like profound traps the enter before the jquery event is fired.
Anyways, what I did is add an event (using profound addEvent) on the element and put the preventEvent in there and it works perfectly.

Thanks a lot
Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 0 guests