ng-pattern 允许小数点前后特定范围内的数字

ng-pattern to allow numbers from certain range before and after decimal

如何限制小数点前后的数字,比如小数点前0-30,小数点后0-15

Correct: 30.15
Wrong: 30.16
Correct: 30.09 or 30.9
Correct: 0.15
Wrong: 0.16
Correct: 21.14
Wrong: 21.56

正在寻找正则表达式。

这个解决方案怎么样?我知道你说的是 RegEx,但这也可以解决问题。

$scope.check = function(value) {

  console.log(value);
  var split = value.split('.');

  var part1Ok = split[0] <= 30;
  var part2Ok = split[1] <= 15;

  $scope.result = part1Ok && part2Ok;
}

http://plnkr.co/edit/nzTNdOR1eWZcwH5zYvIk?p=preview