Search code examples
javascriptangularjsregexng-pattern

Integer only validation for angularjs ng-pattern


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


Solution

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