简体   繁体   English

带有两位小数的输入掩码数字

[英]inputmask numeric with two decimal places

I'm trying to transform my normal input field unto a numeric input with two decimal places using the great plugin called "inputmask" by awesome "RobinHerbots", below snippet is what I tried but sadly and unfortunately its not working, any ideas, help please?我正在尝试使用很棒的“RobinHerbots”的名为“inputmask”的伟大插件将我的普通输入字段转换为带有两位小数的数字输入,下面是我尝试过的片段,但遗憾的是它不起作用,任何想法,帮助请?

 $(document).ready(function(){ $('.decimal').inputmask('decimal', { rightAlign: false, digits: 2, placeholder: "0" }); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js"></script> <input type="text" class="decimal form-control" />

$('.decimal').inputmask({ mask: "99.99"}) // As you requested

OR或者

$('.decimal').inputmask({ mask: "99.9{2}"}) //Same as the first one, {2} mean preceding char count MUST be 2

OR或者

$('.decimal').inputmask({ mask: "(99)|(99.9{1,2})"}) //We use optional here so user can enter 99 or 99.9 or 99.99

Try this尝试这个

https://jsfiddle.net/Ln375fmz/ https://jsfiddle.net/Ln375fmz/

 $('.decimal').inputmask({ mask: "9{0,20}Z9{2}", definitions: { "Z": { validator: "[.]", } }, clearIncomplete: true, autoUnmask: true, placeholder: "", });
 <input type="text" id="money">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM