Angular JS - How do you validate the number of digits in a number input

后端 未结 4 1589
执笔经年
执笔经年 2021-01-28 17:08

What we are looking to do is, have an input that only accepts 0 - 24 (for a time entry application).

These are the values the user should be able to enter into the inpu

4条回答
  •  太阳男子
    2021-01-28 17:30

    Simply add $scope.time1 = parseInt(savedTime) to the end of your function-

    var savedTime = 0;
       $scope.onChange = function(time) {
          if (time > 23 || currentTime > 2) {
            $scope.time1 = savedTime;
          } else {
            savedTime = time;  
          };
          $scope.time1 = parseInt(savedTime);
    };
    

提交回复
热议问题