title: Disable consecutive space in textbox using jquery
body: <p>I want to disable consecutive multiple spaces in asp.net textbox using jQuery.</p>
  
  <p>The textbox should not accept something like </p>
  
  <pre><code>Hello    World
  
   $(document).ready(function () {
              $('#txtFeedDesc').keydown(function (e) {
                  if (e.ctrlKey || e.altKey) {
                      e.preventDefault();
                  }
                  else {
                      var key = e.keyCode;
                      var name = document.getElementById('&lt;%=txtFeedDesc.ClientID %&gt;').value;
                      if (!((key == 8) || (key == 32) || (key == 42) || (key &gt;= 35 &amp;&amp; key &lt;= 40) || (key &gt;= 65 &amp;&amp; key &lt;= 90) || (key &gt;= 48 &amp;&amp; key &lt;= 57) || (key &gt;= 96 &amp;&amp; key &lt;= 105))) {
                          e.preventDefault();
                          return false;
                      }
                      else {
                          if (name.length &lt; 50 || key == 8) {
                              return true;
                          }
                          else {
                              return false;
                          }
                      }
                  }
              });
          });
  </code></pre>
  
  <p>This is the text box that accepts alphanumeric characters. I dnt want two consecutive spaces</p>