如何使jquery.inputmask与input type = number一起使用? [英] How to make jquery.inputmask work with input type=number?

查看:244
本文介绍了如何使jquery.inputmask与input type = number一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要输入类型=文本,我就可以使用此插件正常运行代码,但我想使用type = number,以便在移动设备上显示正确的键盘。

I have the code working fine using this plugin as long as the input type=text, but I would like to use type=number so the proper keyboard is shown on mobile devices.

有没有办法做到这一点,希望我在文档中遗漏了一些设置?

Is there a way to do this, hopefully with some setting I have missed in the documentation?

这是我的html:

<input id="Price" name="Price" type="number" placeholder="0.00" tabindex="3"/>

这是我的js:

$(document).ready(function(){
    $('#Price').inputmask("[9][9]9.99", {
        numericInput: true,
        "placeholder": "0",
        showMaskOnHover: false,
        greedy: false
    });
});


推荐答案

jQuery Inputmask插件( http://plugins.jquery.com/jquery.inputmask/ )使用 setSelectionRange selectionStart selectionEnd (在 https://github.com/RobinHerbots/jquery.inputmask/blob/3.x/js /jquery.inputmask-multi.js )。这些属性/方法已被删除< input type =number/> 字段在Chrome 中。

The jQuery Inputmask plugin (http://plugins.jquery.com/jquery.inputmask/) uses setSelectionRange, selectionStart, selectionEnd (in https://github.com/RobinHerbots/jquery.inputmask/blob/3.x/js/jquery.inputmask-multi.js). These properties/methods have been dropped on <input type="number"/> fields in Chrome when they updated to conform to a W3C change.

如果您认为W3C更改为删除号码字段上的这些功能是错误的,请投票支持 Bugzilla bug#24796

If you feel the W3C change to remove these features on number fields was in error, please vote for the Bugzilla bug #24796

一些黑客攻击以解决此问题,或者您可能需要使用< input type =text>

There are some hacks to workaround this issue or you may need to resort to using <input type="text">

这篇关于如何使jquery.inputmask与input type = number一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆