title: Allow dashes for alphanumeric directive in angularjs
body: <p>I'm using a directive to allow only alphanumeric characters in my fields. I found this directive to do this:</p>
  
  <pre><code>app.directive('onlyAlphabets', function() {
    return {
      require: 'ngModel',
      link: function(scope, element, attr, ngModelCtrl) {
        function fromUser(text) {
          var transformedInput = text.replace(/[^0-9a-zA-Z\s]/g, '');
          console.log(transformedInput);
          if (transformedInput !== text) {
            ngModelCtrl.$setViewValue(transformedInput);
            ngModelCtrl.$render();
          }
          return transformedInput; // or return Number(transformedInput)
        }
        ngModelCtrl.$parsers.push(fromUser);
      }
    };
  });
  </code></pre>
  
  <p>This works fine. Now I want to allow dashes as well. How can i do this?</p>