3

I want to validate decimal no like 0.5,0.05 and also natural no.

For natural no I used this pattern /^[0-9]{1,7}$/.

What pattern I will use for decimal no and natural no together?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mahendra
  • 145
  • 1
  • 1
  • 9

2 Answers2

9

I think this should work. /^[0-9]{1,7}(\.[0-9]+)?$/

Mobin Skariya
  • 392
  • 3
  • 12
0

Use this /^-?[0-9]\d*(\.\d*)?$/

Richard Tun
  • 41
  • 1
  • 7