Formatting input type=number fields with commas and also add min max validation

I currently have a lot of type=number input fields in a form with min and max validation. The input field will display an error message if user enters more than 6 digits for a 6 digit max number field.

But now I have this requirement to format numbers with commas. I know that you cannot enter comma in type=number input fields. If I make it a text field and add a directive to format the string, now the value becomes a string and I cannot perform min/max validation and also the value is stored as a string and not number.

I need help with figuring out how to format the number with commas and as well as add min/max validation and store it as a number not a string.

Source: AngularJS