Example: "1,23/456" should return "123456"
So when I type "1,23/456" in the input field and hit "enter" it should be changed to "123456".
<input id="Id" ng-model="Id" name="searchInput" type="text">
Example: "1,23/456" should return "123456"
So when I type "1,23/456" in the input field and hit "enter" it should be changed to "123456".
<input id="Id" ng-model="Id" name="searchInput" type="text">
Use <input type="number" />
or sanitize the model value using a regular expression.
console.log('1,23/456'.replace(/[^0-9]/g, ''));
If the type of the input is number then it will automatically reject the slash. However I have faced compatibility issues with number fields when testing with IE
So you can register an ng-change or ng-blur event callback on your input field and you can define the callback function like this
$scope.onInputBlur = function(){
//$scope.value is the model for your field
$scope.value = $scope.value.replace(/,/,'','g'); // replace comma with empty string
$scope.value = $scope.value.replace(/\//,'','g'); //replace slash with empty string
}
Hope this helps. :)