I need a function like $("input[type='number']").on("keyup", function(e) that when the user write a number the field format himself. The thousand separator is a comma and the decimal separator is a dot. the decimal number are only 2 because my field it must register money. For example if the user write three number like 123 the field auto format himself to be 1.23 if the user write six numbers it must became 1,234.56 The main issue is that after your field has a comma or a dot inside the function doesn't work anymore.
Asked
Active
Viewed 185 times
0
-
1Does this answer your question? [Equivalent to PHP function number\_format in jquery/javascript](https://stackoverflow.com/questions/12820312/equivalent-to-php-function-number-format-in-jquery-javascript) – Bhagchandani Feb 04 '21 at 07:55
-
when i put 4 numbers in the field the console log "The specified value "8,888" cannot be parsed, or is out of range." and my input reset himself. – roberto perlins Feb 04 '21 at 08:31
-
1It can be because of the comma in the value. you need to remove it before parse. – Bhagchandani Feb 04 '21 at 09:09