Buy Now
Sign in

2 Buttons Event Switcher - Enter Clicked

Gatsman , July 14 at 08:44
Answered
Gatsman
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
H
healyhatman
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
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman
Gatsman
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.