admin管理员组

文章数量:1295854

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).

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

Anybody help me?

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

Sorry my poor english

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).

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

Anybody help me?

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

Sorry my poor english

Share Improve this question asked Dec 4, 2015 at 20:28 Willian CustódioWillian Custódio 6262 gold badges6 silver badges13 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

look at this angular modules and directives:

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

jsfiddle/odiseo/dj6mX/

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

Look at this plugin for jQuery jquery-numberformatter:

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

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

  • Option A: Build custom directive to hide the real box, and put a fake one on top. Just built a proof of concept demo: http://play.ionic.io/app/e3547f0f6b05

  • Option B: Build your own numpad like basically MobiScroll (some paid library) does: http://demo.mobiscroll./numpad/currency/ (works ok with angular and ionic) Update: also check this demo: http://demo.mobiscroll./numpad/variablefraction/

本文标签: javascriptHow auto format input number with currency mask (Ionic)Stack Overflow