title: Angularjs : Restrict special characters on paste event
body: <p>I write the code for restrict special characters in textbox by using Angular Directives.Anyone please tell,how to restrict special characters on pasting in textbox</p>
  
  <p>This is my code:</p>
  
  <pre><code>checks.directive("restrictnosplcharacters", function() {
      "use strict";
      return {
          restrict: "A",
          scope: {},
          replace: false,
          link: function(scope, element, attrs, ctrl) {
              element.bind('keypress', function(event) {
                  if (event.keyCode != 8 &amp;&amp; event.keyCode != 116 &amp;&amp; event.keyCode != 32) {
                      var regex = new RegExp("^[a-zA-Z.]+$");
                      debugger
                      var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
                      if (!regex.test(key)) {
                          event.preventDefault();
                          return false;
                      }
                  }
              });
          }
      };
  });
  </code></pre>