title: How to check if the value in a text box is prime or not with jQuery
body: <p>I am trying to determine whether the value in a text box is prime or not using jQuery.</p>
  
  <p>Here is what I've tried so far, but it's not working:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$("#textbx").keyup(function(){
   if ($("#textbx").val().length &gt; 0) {
     $("#btn").removeAttr('disabled');
   
     }
  });
  
   $("#textbx").blur(function(){
      if ($("#textbx").val().length ==0) {
     $("#btn").attr('disabled','disabled');
   
     }
    });
   
   $("#textbx").keypress(function (e) {
       if (e.which!=8 &amp;&amp; (e.which &lt; 48 || e.which &gt; 57)) {
          $("#msg").html("plz press nimber only").show().fadeOut("slow");
                 return false;
      }
     });
   
    $("#btn").click(function(){
          
     var num =parseInt($("#textbx").val()); 
     var i;
  
     for (var i = 2; i &gt;num/2; i++) { 
     
          if(i%num==0)
    { $("#msg").html("yupp").show().fadeOut("slow");
    }
    else
    {$("#msg").html("huh").show().fadeOut("slow");
    }
    break;
         }
    });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>#msg
  {
      color: red;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input id="textbx" type="text" /&gt;&lt;button id="btn" disabled="disabled"&gt;go&lt;/button&gt;
   &lt;span id="msg"&gt;&lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>JSFiddle version: <a href="http://jsfiddle.net/akash4pj/72FtQ/" rel="nofollow">http://jsfiddle.net/akash4pj/72FtQ/</a></p>