Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

submit on enter

Amal_Elaine
Level 3
Level 3

Is there an event for a field so that they can click the "enter" key and have the form submitted?

1 Accepted Solution
pguerett
Correct answer by
Level 10
Level 10

You can test the xfa.event.commitKey on the exit event of the field. It will return a value of 2 if the user hit enter or a value of 3 if they hit tab.

Paul

View solution in original post

10 Replies
pguerett
Level 10
Level 10

Sure ...a button field exhibits that behaviour.

Paul

Elaine_Schmitz
Level 4
Level 4

Paul, that's not what I'm talking about... The first part of our form is

a search interface - so a user can enter a last name and hit the enter key

- and if so, I want the search to be executed. Right now they havce to

click a button to execute the search. I'd also like the enter key to

simulate the same thing. Any suggestions?

pguerett
Level 10
Level 10

By default the enter key will give you a new line on a multi-line field. If you are in a single line field the enter key will exit the field, so you could execute your code on the exit event of the field.

Paul

Elaine_Schmitz
Level 4
Level 4

Interesting, thanks. - the field is a single line text field. Tabbing

out of the field takes me to the next field, but hitting the enter key

makes the cursor go away and does not position to the next field. Although

the exit event is still fired. Cool for now, thanks.

Elaine_Schmitz
Level 4
Level 4

Actually, I cannot execute my code on the exit event of the field, because

a user should be able to tab out of the field without executing the code,

but should be able to "enter" within the field to execute. Both the tab

and the enter execute the exit event. So the exit event won't work in

this case.... I wonder if I can check on the exit event whether they hit

the tab key or the enter key?

thanks

pguerett
Correct answer by
Level 10
Level 10

You can test the xfa.event.commitKey on the exit event of the field. It will return a value of 2 if the user hit enter or a value of 3 if they hit tab.

Paul

View solution in original post

Jono_Moore
Level 10
Level 10

Could you not also check for no data in the field and not execute the search if nothing is entered?

Elaine_Schmitz
Level 4
Level 4

not really ,because they will be entering data. For example, they can

enter a last name, then tab to the zip code field, enter data, and hit

enter (at which point the search should execute based off the contents of

the last name and zip code fields), or, more simply, they may just want to

enter a last name and hit enter, and not further refine by zip code.

That's just one of three different search methods we are offering.

thanks,

elaine

pguerett
Level 10
Level 10

Is the commitKey approach not acceptable?

Paul

Elaine_Schmitz
Level 4
Level 4

It most certainly is, Paul. I was just answering Jono's question.

Thanks,

Elaine