sevenLee
11/3/2015 - 5:30 PM

From http://stackoverflow.com/questions/14419651/filters-on-ng-model-in-an-input filter: lowcase, no space in real time

app.directive('customValidation', function(){
   return {
     require: 'ngModel',
     link: function(scope, element, attrs, modelCtrl) {

       modelCtrl.$parsers.push(function (inputValue) {

         var transformedInput = inputValue.toLowerCase().replace(/ /g, ''); 

         if (transformedInput!=inputValue) {
           modelCtrl.$setViewValue(transformedInput);
           modelCtrl.$render();
         }         

         return transformedInput;         
       });
     }
   };
});
<input ng-model="sth" ng-trim="false" custom-validation>