Im using a number input that dynamically sets the min and max values based on another form field. I have two scenarios:
- Level 1: Min = 2, Max = 50
- Level 2: Min = 5, Max = 1000
I've set up an ng-change event on the input field to check if the entered number follows the rules for each level. If the number is too high or too low, it gets reset to the minimum.
<input type="number" step="1" ng-change="isValid()" ng-model="level.num" min="{{minNum}}" max="{{maxNum}}">
$scope.isValid = function () {
if( ($scope.level.num > $scope.maxNum) || ($scope.level.nums < $scope.minNum)) {
$scope.tooMany = true;
$scope.level.num = $scope.minNum;
}
};
The issue I'm facing is that when I select Level 1 and try to enter "15", as soon as I type "1" it automatically changes to 2. How can I ensure the number only changes when the user has finished entering their input?