1

How to validate positive integer numbers using ng-pattern. Now i have this pattern ^[0-9]{1,7}(\.[0-9]+)?$/. But it allows decimal values. I need to disallow decimal values too

Kalpa Gunarathna
  • 1,047
  • 11
  • 17
byteC0de
  • 5,153
  • 5
  • 33
  • 66

4 Answers4

1

Very Simple! Just use ^\d+$ where, decimals won't be allowed

Tushar Walzade
  • 3,737
  • 4
  • 33
  • 56
0

try this in ng-pattern ^\-?\d+$ and not accept any -values

zabusa
  • 2,520
  • 21
  • 25
0

Positive integers without leading zeros: ^[1-9]\d+$

Egan Wolf
  • 3,533
  • 1
  • 14
  • 29
-1

Use this expression

ng-pattern="/^[0-9]*$/"

you can check regex on here

Partha
  • 402
  • 4
  • 15