HTML5 Input 输入框type属性控制输入类型

在项目开发中,有许多地方需要限制用户的输入类型。比如说电话号码,身份证号,银行卡号,数量等等,我们可以通过HTML5的type属性来控制用户的输入或者直接限制用户的输入法。可以使用 this.style.imeMode='disabled' 来关闭用户的输入法。

 <input type="text" onfocus="this.style.imeMode='disabled';" /> 

imeMode还有其他四种属性供我们根据需求来控制输入:

1 imeMode='auto'         //打开输入法(默认)
2 imeMode='disabled'   //关闭输入法
3 imeMode='active'       //中文输入法
4 imeMode='inactive'    //英文输入法

Android手机暂时不可用,可使用 type='number'代替。
posted @ 2017-02-08 10:54  丶镜心  阅读(5066)  评论(0编辑  收藏  举报