angularjshtmlangularjs-directiveangularjs-ng-model

AngularJS number input formatted view


I want to use a formatted number input to show thousand seperator dots to user when he types big numbers. Here is the directive code that I used: http://jsfiddle.net/LCZfd/3/

When I use input type="text" it works, but when I want to use input type="number" it's weirdly cleaning by something when user typing big numbers.

What is problem about input[number]?


Solution

  • As written in the comments, input type="number" doesn't support anything but digits, a decimal separator (usually , or . depending on the locale) and - or e. You may still enter whatever you want, but the browser will discard any unknown / incorrect character.

    This leaves you with 2 options:

    The latter solution uses an additional <label> tag that contains the current value and is hidden via CSS when you focus the input field.