-3

I have searched a lot also tried but it is not working for me. I am using java script.

Alan Moore
  • 73,866
  • 12
  • 100
  • 156

1 Answers1

1

Providing that

  1. Both borders are included (so 0.00 and 20.00 are valid)
  2. Two digits after the decimal point are mandatory (5 in invalid, but 5.00 is OK)
  3. Leading zeros are invalid (so 05.00 is invalid)

the regular expression can be

(^1?[0-9]\.[0-9]{2}$)|(^20\.00$)

Edit: if requests are

  1. Both borders are included (so 0.00 and 20.00 are valid)
  2. There're at most two digits after the decimal point(5, 5.1, 5.12 are valid, but 5.123 is not)
  3. Dangling dots are not allowed (5. is not valid)
  4. Leading zeros are invalid (so 05.00 is invalid)

the regular expression can be

(^1?[0-9](\.[0-9]{1,2})?$)|(^20(\.0{1,2})?$)
Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215