Decimal number is not a number!

You have an input field, where user can enter decimal values. Problem is, that some cultures use decimal point “.” and some uses decimal comma “,”. So what is a valid number in one culture, is not a number at all in a different culture. You can see the full list of differences on wikipedia. There is no built-in validator for numbers in Angular, so we have built our own like this: import { AbstractControl, ValidatorFn } from ‘@angular/forms’; export class NumberValidators { static isNumber(): ValidatorFn { return (c: AbstractControl): { [key: string]: boolean } | null => { if (isNaN(c.value)) { return { …

Continue Reading