Sunday, 29 June 2008

Textfield Item - Submitting the Page

Normaly, if there are page items of type "Text Field" they will not submit the page unless you change them to "Text Field (always submits page when Enter pressed)". If you have only one item on you page of type "Text Field" this behaviour changes and the page will always submit if you press "Enter". Sometimes, you don't want this to happen. Especially, if you have some javascript attached to your field. To avoid that you can use the following trick:

1. create another item on you page of type "Text Field",

2. in the "HTML Form Element Attributes" of that item put

style="display:none"

The result is that the second item will not be displayed and the first item will not submit on pressing "Enter".

6 comments:

Anonymous said...

Now I finally know why some of my text fields do a submit without that I have told them to do so.

Thanks for the hint :).

Apex Rookie User said...

Very nice topic! I was having some headaches because this, thanks a lot!!

Sydney said...

Thanks Denes,

I had a one-item page (for updating) and using a barcode-scanner for input. It always 'generated' a press Enter without me submitting. Your 'trick' works fine!

Robert Stefanov said...

13 years later. APEX is 20.2. It still works.

Anonymous said...

Still works in 2022, I have a barcode scanner that automatically enters. Just added the second text field and hiding it works like a charm. Thank you!

-Eva

Eva said...

Added the extra item and hid it, works like a charm in 2022, the automatic enter is disabled. Thank you!