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,
prevent submit onEnter for one element
-
- Profound User
- Posts: 41
- Joined: Fri Aug 16, 2013 7:23 am
- First Name: Sebastien
- Last Name: Gagne
- Company Name: Oceanex
- Contact:
-
- 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
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
preventEvent() is documented here:
http://www.profoundlogic.com/docs/displ ... +event+%29
-
- 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
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
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
Who is online
Users browsing this forum: No registered users and 1 guest