mardi 26 janvier 2016

Formatting currency in Ember

I have a form with several input fields for entering amounts of money and shows the total at the bottom of the screen. I would like for the user to only be able to type in numeric digits [0-9], then a decimal ., and then a maximum of two more digits.

At first, I used the Ember addon ember-inputmask which correctly formats the currency as I needed, but if I clicked on an input and clicked out without entering a number or if I only entered part of a number and clicked else where the total would equal NaN.

I have also attempted to import the jQuery plugin autonumeric.js through npm and use that but with no success.

What is the best approach to only allow currency to be typed in an input field in Ember?

Is there a better addon or resources on how to accomplish this?




Aucun commentaire:

Enregistrer un commentaire