I have tried to validate my input quantity field by using pattern attribute. But my regular expression not working. Please check
^(?:[1-9]\\d*|)$
You may check by yourself:
https://regex101.com^(?:[1-9]\d*|)$
^(?:[1-9]*)$
Should be enough.
If you want to match multiple numbers 1-9
use:
^[1-9]*$
This regex is as good as it gets with regard to checking for NULL
values. If you want to also allow nulls, then you should include this logic explicitly in your controller, i.e.
form.input.$valid || quoteList.quantity === null
Update:
It appears that what you really wanted to ask is how to validate a number which begins with 1-9
, but then can be followed by any digit. If so, then try this regex:
^[1-9][0-9]*$
Again, you can check in your controller for null values and also allow them too.