JavaScript prevents carriage return submission of forms _javascript tips

Source: Internet
Author: User

You should be familiar with the function of the ENTER key, for example, in many Windows applications, you can enter this program or turn on a function by clicking Enter, but sometimes we want to block its function, for example, when filling out a form, you may accidentally click the ENTER key to cause the form to submit incorrectly, Here's a quick introduction to how to implement this feature. The code example is as follows:

How to Prevent carriage return (enter) key submission form, in fact very simple, on the one word. Onkeydown= "if (event.keycode==13) return false;" It would be nice to write this sentence in the from tag.

<! DOCTYPE html> 
 

The above code can mask the function of submitting the form by clicking Return. The code is easy to understand, there is no clear welcome to put forward valuable comments, thank you all have been the cloud-Habitat community website support.

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.