Want to Submit form on enter/return

I have a search form with an input field and a button. I would like to submit the form if the user hits enter/return. I will still submit with the search button but want the option of just hitting enter as well. How can I accomplish this? Thanks! Ken

You have not stated what the search form will be searching. If this is the site’s databasebase, then have look at https://docs.wappler.io/t/filtering-database-query-with-a-text-input/2869

Thanks Ben, I have the search working fine, I just want to submit the form when the user hits enter/return, so they don’t have to hit the search button. I have had admins tell me the search isn’t working and it’s because they entered the search term and hit enter without pressing the button.

On keyboard key press dynamic event of the input box, set Enter key in key field, and select formname.submit() from the action picker.

3 Likes

Thanks Sid, worked perfect!

1 Like

@sid, how to implement this solution on AutoComplete? I tried with Dynamic Events -> Value Updated but I can’t choose the modifier (submit only when user press enter). Any idea?

Hi. Did not really get your point.
You want to submit the form after user has selected item from autocomplete and thes presses enter on the same field?

1 Like

If you want to submit the form when a selection is made, you don’t need to trigger a keypress - just use the submit action:

image

1 Like

@sid yes! Correct!
@TomD I tried this and works, but it submits the form automatically, I would like to submit after the value is updated and enter key pressed!

Thank you guys for replying!

So on key press, you can use inline flow.
The flow would have condition like if autocomplete1.value, then form1.submit else do nothing.
So, in case someone pressed enter key without selecting anything, nothing would happen.
And if they press enter after selecting an item, it should submit the form.

What I don’t get is the user has already probably pressed enter when selecting an item from autocomplete. Why do you want them to press enter again?