javascript 如何使用货币掩码自动格式化输入数字(离子)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34096872/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 17:14:21  来源:igfitidea点击:

How auto format input number with currency mask (Ionic)

javascripthtmlinputionicmask

提问by Willian Custódio

I need to create a currency mask (right to left) in a input=number of my mobile app (Ionic + Cordova). If the user enter with 123456 value, the input should be 1.234,56 (adding "," and "." automatically).

我需要在我的移动应用程序(Ionic + Cordova)的 input=number 中创建一个货币掩码(从右到左)。如果用户输入 123456 值,则输入应为 1.234,56(自动添加“,”和“.”)。

I don't know how to do this with HTML and Javascript.

我不知道如何用 HTML 和 Javascript 做到这一点。

Anybody help me?

有人帮我吗?

Noting that input type should be "number", to show only numeric keyboard in device.

请注意,输入类型应为“数字”,以仅显示设备中的数字键盘。

Sorry my poor english

对不起我可怜的英语

回答by Kiramishima

look at this angular modules and directives:

看看这个角度模块和指令:

http://aguirrel.github.io/ng-currency/

http://aguirrel.github.io/ng-currency/

jsfiddle.net/odiseo/dj6mX/

jsfiddle.net/odiseo/dj6mX/

http://assisrafael.github.io/angular-input-masks/

http://assisrafael.github.io/angular-input-masks/

回答by Crisboot

I know your pain, I've seen a couple of solutions:

我知道你的痛苦,我已经看到了几个解决方案:

回答by Maxim Goncharuk

Look at this plugin for jQuery jquery-numberformatter:

看看这个 jQuery jquery-numberformatter插件:

$(this).parseNumber({format:"#,###.00", locale:"us"});