Guest User

Untitled

a guest
Dec 11th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. convertCurrency = (input) ->
  2. value = $(input).val().replace /[^\d\.]/g, ''
  3. float = parseFloat(value)
  4. float = 0 if isNaN(float)
  5. precision = parseInt(input.attr('data-precision'))
  6. if precision is 0
  7. val = float.toString().replace /\.\d*/, ''
  8. else
  9. val = float.toString().replace new RegExp("(\\.\\d{#{precision}})\\d*"), '$1'
  10. val = parseFloat val
  11. $(input).val val || ''
Add Comment
Please, Sign In to add comment