title: Jquery do not recognize the function I called
body: <p>I am trying to call a Javascript function that I referenced in the View but I am getting an error that the function is not 'function'</p>
  
  <p>I have tried to call and renaming it but I have not succeeded.</p>
  
  <p>Here is the function that is in the external JS file</p>
  
  <pre><code>$.fn.onlyNumb = (function () {
  
          $(this).on('keypress', function () {
              try {
                  var val = $(this).val();
                  if (isNaN(val)) {
                      val = val.replace(/[^0-9\.]/g, '');
                      if (val.split('.').length &gt; 2)
                          val = val.replace(/\.+$/, "");
                  }
                  $(this).val(val); 
              }
              catch (err) {
                  alert(err.Description);
              }
          });
  
      });
  </code></pre>
  
  <p>This is How I referenced the JS and called the function</p>
  
  <pre><code>&lt;script type="text/javascript" src="~/Scripts/MyCustomScripts.js"&gt;&lt;/script&gt;        
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $(".payslip").each(function (i, obj) {
              $(this).onlyNumb();
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>I expect that the error should not be there because I referenced the external jS file well and called the function as expected.</p>