@RalfiSlask
Posted
You should probably make use of a boolean variable.
- First declare lets say buttonPressed = false.
- Change it to true in your click event listener for the buttons.
- Create an if else statement in the click event for the submit button.
- In the if-statement write if(buttonPressed === true) or if(buttonPressed) which is the same and in the if block write out your code.
- In the else statement you can either apply an alert (this is not very pretty though) or attach lets say a red error message on the container that lets the user know they need to press one of the buttons.
Good Luck!
@d8701a
Posted
@RalfiSlask This was such an elegant solution! I implemented it right away, and it worked like a charm. I agree displaying a simple alert message looks inelegant (and rather aggressive indeed), but for my demo purposes it served.
I can't believe I completely forgot about the power of boolean values.
Thank you so much for this, it was short, simple and efficient!