Home >Web Front-end >HTML Tutorial >Simple implementation of 'Enter!=Submit' (remove the form's Enter to submit)_html/css_WEB-ITnose

Simple implementation of 'Enter!=Submit' (remove the form's Enter to submit)_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:02:591080browse

-------------------------------------------------- -------------------------------------------------- ----

To realize the problem of "Enter!=Submit", you can generally start from the "type of button" and "number of input boxes".

---------------------------------@chenwei ---- -----------------------------

By default, a single input box, regardless of the button's type="submit" or type="button" type, press Enter to submit.

1. When type="submit", no matter how many type="text" input boxes there are, pressing Enter means submission. (submit)

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

3. To solve the problem of pressing Enter to submit a single input box, refer to the second point: you can add an input="text" and hide it; then the type is button.

In actual applications, there is rarely only one input box, so you only need to remember the second item to deal with it.

Using JS events to prevent form submission is beyond the scope of this article, but of course it can be implemented.

-------------------------------------------------- -------------------------------------------------- ----

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn