Reputation: 119
what I'm trying to do here is next
I need a simple input that allows for numbers from 5 to 10, and 0
`<input type="number"
required ng-model="item.quantity"
ng-min="5"
ng-max="10"/>`
this is my code but it now valid when user insert 0
Upvotes: 1
Views: 88
Reputation: 56946
For this regex:
ng-pattern="/^(0|[5-9]|10)$/"
The following are valid:
0, 5, 6, 7, 8, 9, 10
Upvotes: 1
Reputation: 67
Use like,
html:
<input type="number" required ng-model="item.quantity"/>
controller:
$scope.$watch("item.quantity", function() {
var quantity = parseInt(item.quantity);
if(quantity => 5 || quantity == 0) {
//To do
} else {
$scope.item.quantity = '';
}
});
Upvotes: 0