Simple implementation & quot; press Enter! = Submit & quot; (remove the form and press enter to submit)

Source: Internet
Author: User

Bytes --------------------------------------------------------------------------------------------------

Implement "press Enter! = Submit. Generally, you can start with "type" of the button and "Number of input boxes.

---------------------------- @ Chenwei <www. chenwei. ws> -------------------------------

By default, no matter the type = "submit" or type = "button" type of the button in a single input box, press enter to submit.

1. When type = "submit", whether there are several type = "text" input boxes, press enter to submit. (Submit)

2. When type = "button" and there are multiple input boxes, press enter to not submit. (Button)

3. Solve the Problem of submitting a single input box by pressing enter. Refer to the second point: you can add an input = "text", hide it, and set the type to button.


In practice, there is only one input box, so you only need to remember the second one.

Blocking form submission by using JS events is not covered in this article. Of course, it can also be implemented.

Bytes --------------------------------------------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.