I use angular/ui-mask in my project. Now I need a mask for block ip address range (example 192.168.70.18/20). For example:
<input ng-model="address" ui-mask="9?9?9.9?9?9.9?9?9.9?9?9/9?9" ui-mask-placeholder-char="_" placeholder="" ng-disabled="disabled">
The problem is so I can only enter this IP address: 192.168.125.254
I think this solve your problem:
$scope.$watch('address', function (address) {
if (!address || address.length < 15) return;
var endFrom = parseInt(address.substr(9, 3)),
endTo = parseInt(address.substr(12, 3));
if (endFrom > endTo) {
alert('invalida range');
$scope.address = address.substr(0, 12);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.