Copy link to clipboard
Copied
Hi,
I have three buttons and their type also are button. Let's say "Cancel", "Send", "Search". I want to set the default button when user presses "enter".
For example, when user inputs some data in a textbox and press "enter", the form will perform the action of "Send". However, I only want the form to perform "Search" when user presses "enter".
Since "Send" action will submit the form and "Search" action will not submit the form, I set none of them is submit type.
Is it possible to set the default button to "Search".
Make the search button an input of type = submit. Make the Send button an input of type = button and write an onclick event for it.
Copy link to clipboard
Copied
You should be able to capture the button press with javascript and set the action type before submission.
Copy link to clipboard
Copied
Make the search button an input of type = submit. Make the Send button an input of type = button and write an onclick event for it.