Tonyukuk
Tonyukuk

Reputation: 6195

how to get range of numbers in validation pattern

I want to validate numbers between 2009-2059 in validator pattern at typeScript code. I tried many ways but could not find a way to do it ? Could you please look at the sample code and tell me how to fix it ?

Regards Alper

you can see the sample code below.

],'Input3': [this.guiTranformatorInput.JJJJ_input3,[
Validators.required,
 Validators.pattern('20[0-5][8-9]'),
  ]

Upvotes: 1

Views: 1865

Answers (1)

Tiep Phan
Tiep Phan

Reputation: 12596

your range pattern is wrong, try this

20((09)|([1-5][0-9]))

20: start with 20
(
09: literal 09
or
1-5 and 0-9
)

or using custom validator: https://stackoverflow.com/a/39848327/3676586

Upvotes: 2

Related Questions