jQuery掩码编号,带逗号和十进制 [英] Jquery Mask number with commas and decimal

查看:101
本文介绍了jQuery掩码编号,带逗号和十进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jquery掩码插件来格式化我网站上的许多内容,并且我试图找出如何以所需的方式来格式化数字.我正在使用以下插件.

I am using a Jquery mask plugin to format many things on my site and I am trying to figure out how to get it to format numbers in the way I need. I am using the following plugin.

https://igorescobar.github.io/jQuery-Mask-Plugin/

我正在尝试使用以下格式的电话号码.

I am attempting to get the following format for my numbers.

999,999,999.99

数字是一个货币字段,需要每三位数添加一个逗号,并且值可以低至0.00

The number is a currency field that needs a comma added every three digits and the value can be as low as 0.00

推荐答案

嗯,这行得通.我只是从网站上修改了示例,用逗号更改了点,然后它就起作用了.

Well, this worked. I just tweaked the example from the website changing dots with commas and it worked.

$('.money').mask("#,##0.00", {reverse: true});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.13.4/jquery.mask.min.js"></script>

<input class="money" type="text"/>    

如您所见,数字没有限制.如果要限制它们,可以执行$('.money').mask('000,000,000,000,000.00', {reverse: true});

As you can see there is no limitation of numbers. If you want to limit them, you can do $('.money').mask('000,000,000,000,000.00', {reverse: true});

这篇关于jQuery掩码编号,带逗号和十进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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