Mobile input gets focus after popup with enter (similar to search, OK, go to) keyboard, as well as hide system keyboard

Source: Internet
Author: User

One: Bring up the system with enter key keyboard

In the project there are often input boxes, when the input is completed click OK to perform the corresponding action. However, some of the design is not determined or search button, this need to call the system keyboard, click on the system keyboard to perform the corresponding action.

But the simple input is not possible, to call the keyboard with a carriage return must put input in the form form can be, and have to add action (must add), the following is a simple example.

<formAction Class= "Search"onsubmit= "return false;">    <Iclass= "fa fa-lg fa-search"></I>    <inputtype= "text"class= "Search-input"placeholder= "Search"><Iclass= "fa fa-lg fa-times-circle clear-search"></I></form>

Here, in order to avoid the page refresh caused by the form submission, add a onsubmit= "return false;".

Second: Hide the system keyboard after canceling

If you want to cancel the cursor on your PC, you can click on any other part of the page, but clicking on other unbound events on your phone will not remove the cursor. Here are three ways to

Hide the keyboard and choose the simplest one on the project.

1. The simplest one, direct <a href= "javascript:" class= "Search-close" > Cancel </a>

2. Use JS or JQ directly to lose focus on the input box, you need to bind an active Defocus event.

3. Set a label that is not a label, arbitrarily binding a click event can be, even if the method does not write anything.

Mobile input gets focus after popup with enter (similar to search, OK, go to) keyboard, as well as hide system keyboard

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.