1

I have input text field (type = string) which should accept number as input but the number format should be validated based on the defined locale code.

var number = '2,110.168';
if locale is en-in, this should be valid
if locale is nl-nl, this is not a valid format as it should be 2.110,168
georgeawg
  • 47,985
  • 13
  • 70
  • 91
kiran gudla
  • 157
  • 1
  • 9

1 Answers1

1

You can use Number.toLocaleString() which returns the "language-sensitive representation" of a number.

If your input is in a form, you can create a custom validator to validate its value.

JoH
  • 444
  • 1
  • 6
  • 14