数字和小数的输入掩码 [英] Input mask for numeric and decimal
问题描述
在测试我的程序后,我意识到一个软件应用程序管理发票我注意到以下错误:
我在sqlserver中的表包含:price numeric(6,2)
我的程序的用户输入价格为555.00是不错的。
但是当他把555555这是错误的,所以我需要指定掩码的尾数是可选的0到999,小数部分可根据用户的选择设置为2或3,我使用的是JQuery Masked input插件和我还没有找到好的正则表达式,请帮忙,我正在使用jsp / servlet。 对于数字使用 jquery数字。
当前版本确实允许您在重新寻找,但有人更改了该代码,它的工作原理:
$ b HTML
< input class =numeric type =text/>
Javascript
$(。numeric)。numeric({decimal:。,negative:false,scale:3});
这是整个 source 。
我已经准备好>小提琴,这样你就可以看到它是如何工作的。
I realized a software application management invoicing after having tested my program I noticed the following error: my table in sqlserver contains: price numeric (6,2) the user of my program enter price as 555.00 is good. but when he put 555555 it's error, so I need to specify the mask where the mantissa is optional 0 to 999 and the decimal part is programmable 2 or 3 according to choice of the user, I'm using JQuery Masked input plugin and I have not found good regular expression, please, help, I'm working with jsp / servlet.
You can use jquery numeric for numbers.
The current version does allow what you're looking for but someone has changed the code a little bit and it works:
HTML
<input class="numeric" type="text" />
Javascript
$(".numeric").numeric({ decimal : ".", negative : false, scale: 3 });
This is the whole source.
And I've prepared this fiddle so you can see how it works.
这篇关于数字和小数的输入掩码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!