Skip to Main Content

Prevent submit APEX form when pressing enter on text field

APEX text item have option "Submit when Enter pressed" to submit page with item name as request.

This attribute seems not work when you have only one text item on page. Even you set this attribute to No, pressing enter will submit page but requests is empty. This is not always good and might be also annoying and miss lead end users how form actually work.

To prevent text items submit page when pressing enter, add to page JavaScript Execute when Page Loads:

 return e.keyCode!==13;


  • Vishal 25 Sep 2014

    Yah its really work...

  • Jari Laine 8 Sep 2012

    Hi Apodictus,

    Thanks for info.

    Regards, Jari

  • apodictus 7 Sep 2012
    Hi, This is caused by the browser, not apex. Somehow browsers decides when you have a form with only 1 item enter means it should post. It can even be worse. Try having 1 textfield item and 1 texarea item. (eg. enter a value + a description of the value) The browser will still see this as 1 item (ignoring the textarea) and post. This drove me nuts a while back. Anyaway. Apart from your nice jquery solution, you could also simply add a second hidden page item. (PX_DUMMY) This will also cause the browser to see 2 items and thus stop posting on enter. Apodictus