1

How to limit numbers for before and after the decimal point, something like before decimal should be from 0-30 and after decimal should be from 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

Looking for a regEx.

User2309
  • 35
  • 1
  • 5
  • regEx. only validates elements quantity not element value. ex. ´[1-5]{1,2}´ this only checks that have 1 or 2 elements and each can be 1 to 5 but the order cant control. I would recomend to check angularjs validations. – Jesus Carrasco Aug 04 '17 at 18:50

1 Answers1

1

How about this for a solution? I know you said RegEx, but this could do the trick as well.

$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

Brian
  • 4,921
  • 3
  • 20
  • 29