Buy Now
Sign in

2 Buttons Event Switcher - Enter Clicked

Gatsman , July 14 2018
Gatsman 297
July 14 2018 #379052
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
healyhatman 5.7
July 14 2018 #379053
 Answer
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

You can now copy+paste code from forums
Gatsman 297
July 21 2018 #379175
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.