HTML prevents input from being submitted by enter form

Source: Internet
Author: User

>html prevent input Enter to submit form

Auto-Submit Status Note:

1. By default, a single input box, regardless of the button's type= "Submit" or type= "button" type, the carriage return is submitted.
2. When type= "submit", no matter how many type= "text" input box, the carriage return will indicate the submission. (The default type of the <button> button is submit)
3. When type= "button" and there are multiple input boxes, the carriage return is not committed. (Button)

Solution:
1. Resolve a single input box to enter the problem of submission, you can add a hidden input= "text" display= ' none '; Then type is button.
2. In the form form or input, add: onkeydown= "if (event.keycode==13) {return false;}"

HTML prevents input from being submitted by enter form

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: info-contact@alibabacloud.com 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.