Currently, I am implementing the ng-pattern
argument in an input text field to restrict input to only numeric values:
<input type="text" ng-model="numericField" ng-pattern="/^[0-9]*$/" />
However, there seems to be an unusual behavior in the regex evaluation: spaces at the beginning and end are being disregarded...
For example, when I enter these values:
' 123 '
the pattern is matched
' 123 4343 '
the pattern is not matched
In my scenario, I require that white spaces are not allowed at any position within the string.
Update: I also need to address this issue for other inputs that allow character values such as email addresses.
How can I go about solving this problem?