Forums

2 Buttons Event Switcher - Enter Clicked

Gatsman 14 Jul, 2018
Hi, i have a problem with a form that has 2 buttons and an event switcher to handle what button was clicked.
The problem appears when instead of a button click the user hits Enter on the keyboard (he has to be in the input field).
In that case none of the events is called.
How can i have a "default" button/event that will be called on keyboard Enter?

I created a demo form to show the issue, just write something in the input and click keyboard Enter[file=10770]Enter_Event_14_Jul_2018_10_42_37.cf6bak[/file]
healyhatman 14 Jul, 2018
Answer
1 Likes
Two options.

1) Use JavaScript to detect when the enter key is pressed and discard the event / prevent default.
2) At the top of your submit event, have another event switcher that checks for {data.empty:button} if True use a custom code with {data.set:default} (replace default with whatever you want your default value to be), or maybe use an event loader to redo the initial event and display an error message saying they have to click a button. the Don't bother with the False condition
Gatsman 21 Jul, 2018
Thank you for the reply.
The use of the Enter key is a must in my form.
My secondary events have redirects so i moved the one that i want to be the default after the event switcher that way if no other event gets called it goes to the default.
This topic is locked and no more replies can be posted.