Mobile return return contact form submission and related compatibility

Source: Internet
Author: User
Tags contact form

Sometimes we want the enter key to be in the text box (input Element) to submit the form (form), but sometimes it's not desirable. such as search behavior, I hope to enter the keyword immediately after the key to submit the form, and some complex forms, you may want to avoid the enter error operation when the completion of the form to fill out the form to trigger the submission of forms.

To control these behaviors, do not need to use JS, the browser has helped us do these processing, here summarizes a few rules:

    1. If there is a type= "submit" button in the form, the ENTER key will take effect.
    2. If there is only one type= "text" Input in the form, the enter takes effect regardless of the type of the button.
    3. If the button is not with input, but with a button, and no Type,ie is added, the default is type=button,fx default to Type=submit.
    4. Other form elements such as textarea, select Do not affect the Radio checkbox does not affect the triggering rules, but itself in the FX will respond to the enter, under IE do not respond.
    5. Type= "image" input, the effect is equivalent to type= "submit", do not know why the design of such a type, is not recommended, should be used to add a CSS background map appropriate.

In practice, it is easy to make the form respond to the ENTER key, which is guaranteed to have a type= "submit" button on the form. What happens when there is only one text box and you don't want to respond to the ENTER key? My method is a bit awkward, is to write a meaningless text box, hidden. According to rule 3rd, when we use the button, we try to declare the type as explicitly as possible to make the browser behave in a consistent way.

Above transfer from http://blog.csdn.net/dac55300424/article/details/39158759

For Mobile, iOS can insert a meaningless text box hidden and listen for the ENTER key to do other processing. At this point the form is processed by listening.

Android is not recommended to insert, after inserting the return key is not valid, also listen to enter and prohibit the default event. At this point the form is processed by listening.

When the mobile side hits the carriage return, the iOS is suspected of submitting the form before triggering the listener. Further research is needed.

Mobile return return contact form submission and related compatibility

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: 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.