I have an input form field, of type number, that I am attempting to let Angular validate (which seems excellent so far), however I cannot seem to get the correct syntax for dynamically creating a regex to apply to ng-pattern that restricts the user to a range of numbers from min and max values that are passed to the controller after a json call.
This was quick and helpful:
ng-pattern for only numbers will accept chars like '-' in angular.js
So I initially set this on the ng-pattern and it works, but allows numbers outside the min & max range:
$scope.onlyNumbers = /^\d/;
However, I need to make the regex on the fly and make it a range, so I tried without much success:
$scope.onlyNumbers = new RegExp(".{" + $scope.min + "," + $scope.max + "}", "g");
I'm not a RegEx expert, obviously.
Any help is appreciated.
Thanks in advance!