title: object doesn't support this property in jquery mvc4
body: <pre><code>@Scripts.Render("~/bundles/jquery", "~/bundles/jqueryui", "~/bundles/WorkbenchScripts")
  @Styles.Render("~/Content/WorkbenchCss")
  &lt;script type="text/javascript"&gt;
  
      $(document).ready(function () {
          checkSpecialChars('#txtCreateSet');
          $('#btnCancelSet').click(function (e) {
              window.close();
          });
      });
  
  
      //this function is used to allow only specific characters in function
      function checkSpecialChars(textboxID) {
          debugger;
  
          return textboxID.each
              (
                  function () {
                      var allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                      allowedChars += "abcdefghijklmnopqrstuvwxyz";
                      allowedChars += "0123456789";
                      allowedChars += " "; //Space
                      //Check if try to specifying allowed special characters for Name fields
                      allowedChars += "-_";
                      //on keypress
                      $(textboxID).keypress(function (e) {
                          var keyUniCode = !e.charCode ? e.which : e.charCode;
  
                          var charValue = String.fromCharCode(keyUniCode);
  
                          if (keyUniCode != 13) {
                              if (allowedChars.indexOf(charValue) == -1)
                                  e.preventDefault();
                          }
                      });
                      //On paste
                      $(textboxID).bind('paste', function (e) {
                          setTimeout(function () {
                              var newText = textboxID.val();
                              $.each(newText, function (i) {
                                  if (allowedChars.indexOf(newText.charAt(i)) == -1)
                                  { textboxID.val(textboxID.val().replace(newText.charAt(i), '')); }
                              });
                          }, 1);
                      });
                  }
              );
              };
  &lt;/script&gt;
  
  
  
  
  
  
  &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                @Html.Label("Create Set")
              &lt;/td&gt;
              &lt;td&gt;
               @Html.TextBoxFor(model =&gt; model.SetName, new { id = "txtCreateSet" })
              &lt;/td&gt;
          &lt;/tr&gt;
  &lt;table&gt;
  </code></pre>
  
  <p>In the above code i am getting the error "object does not support this property",i am using MVC4  and here i have written the code in mvc view that in the textbox only characters allowed are 0-9 a-z A-Z - _ and space characters.Where i am doing wrong?can anyone help me to get the desired solution?</p>