Home  >  Article  >  Web Front-end  >  Remove the form's carriage return and submit, carriage return!=submit

Remove the form's carriage return and submit, carriage return!=submit

高洛峰
高洛峰Original
2017-03-01 14:49:461554browse

By default, for a single input box, regardless of the type="submit" or type="button" type of the button, the carriage return is submitted. So how to remove the carriage return of the form and submission? Here is a good example. For reference To solve the problem of "Enter!=Submit", you can generally start from "the type of button" and "the number of input boxes".

By default, for a single input box, regardless of the type="submit" or type="button" type of the button, 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 without submitting. (button)

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

In practical 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.

For more information about removing the carriage return from the form, submit and carriage return! = Submit related articles please pay attention to the PHP Chinese website!

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