title: Form Search Onkeyup event
body: <p>I have a form in which the form should automatically search when I complete entering the 10th character in the text field but the below code is searching for each n every character I enter in the text field . . . I just want the result after completing the 10th character not for each n every character . . I have used <code>onkeyup</code> event and I set that value to 10 but still it is searching for each n every character... please do help me</p>
  <pre><code>&lt;body OnKeyPress=&quot;return disableKeyPress(event)&quot;&gt;
  &lt;section id=&quot;content&quot; class=&quot;container_12 clearfix&quot; data-sort=true&gt;
      &lt;center&gt;&lt;table class='dynamic styled with-prev-next' data-table-tools='{'display':true}' align=center&gt;
          &lt;script&gt;
          function disableEnterKey(e)
          {
              var key;      
              if(window.event)
                  key = window.event.keyCode; //IE
              else
                  key = e.which; //firefox      
  
              return (key != 13);
          }
  
          function showUser(str)
          {
  
              if (str==&quot;&quot;)
              {
                  document.getElementById(&quot;txtHint&quot;).innerHTML=&quot;&quot;;
                  return;
              } 
              if (window.XMLHttpRequest)
              {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
              }
              else
              {// code for IE6, IE5
                  xmlhttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
              }
              xmlhttp.onreadystatechange=function()
              {
                  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
                  {
                      document.getElementById(&quot;txtHint&quot;).innerHTML=xmlhttp.responseText;
                  }
              }
              xmlhttp.open(&quot;GET&quot;,&quot;resdb.php?id=&quot;+str,true);
              xmlhttp.send();
          }
          &lt;/script&gt;
  
          &lt;script type='text/javascript'&gt;
          //&lt;![CDATA[ 
          $(window).load(function(){
              $('#id').keyup(function(){
                  if(this.value.length ==10)
              });
          });//]]&gt;  
  
          &lt;/script&gt;
  
  
  
          &lt;form id=&quot;form&quot; method=&quot;post&quot; name=&quot;form&quot; &gt;
              &lt;tr&gt;&lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;b&gt;JNTUH - B.Tech IV Year II Semester (R07)   Advance Supplementary Results - July 2012&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;b&gt;Last Date for RC/RV : 8th August 2012&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;
              &lt;tr&gt;&lt;td&gt;&lt;p align=&quot;center&quot;&gt;&lt;/b&gt; &lt;input type=&quot;text&quot; onkeyup=&quot;showUser(this.value)&quot;   onKeyPress=&quot;return disableEnterKey(event)&quot; data-type=&quot;autocomplete&quot;  data-source=&quot;extras/autocomplete1.php&quot; name=&quot;id&quot; id=&quot;id&quot; maxlength=&quot;10&quot; placeholder=&quot;Hall-Ticket Number&quot;&gt;&amp;emsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;/form&gt;
      &lt;/center&gt;
  &lt;/table&gt;
  &lt;center&gt;
      &lt;div id=&quot;txtHint&quot;&gt;&lt;b&gt;Results will be displayed here&lt;/b&gt;&lt;/div&gt;
  &lt;/center&gt;
  &lt;/body&gt;
  </code></pre>