Mahendra
Mahendra

Reputation: 115

How to validate decimal no using ng-pattern in angularJs?

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?

Upvotes: 3

Views: 12562

Answers (2)

Richard Tun
Richard Tun

Reputation: 41

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

Upvotes: 0

Mobin Skariya
Mobin Skariya

Reputation: 392

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

Upvotes: 9

Related Questions