Page 1 of 1

prevent submit onEnter for one element

Posted: Thu Jan 22, 2015 10:17 pm
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,

Re: prevent submit onEnter for one element

Posted: Fri Jan 23, 2015 12:54 pm
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

Re: prevent submit onEnter for one element

Posted: Fri Jan 23, 2015 4:10 pm
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