Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Default button in form

Guest
Jun 04, 2012 Jun 04, 2012

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".

538
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jun 05, 2012 Jun 05, 2012

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.

Translate
Community Beginner ,
Jun 05, 2012 Jun 05, 2012

You should be able to capture the button press with javascript and set the action type before submission.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 05, 2012 Jun 05, 2012
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources