title: Number validation using jquery
body: <pre><code>$('#empcontact').blur(function(){
          var stri = $('#empcontact').val();//the input element
          var numbers = "0123456789";
          var flag = false;
          for(var x=0;x&lt;stri.length;x++){
              var ch = stri.charAt(x);
              var n = numbers.indexOf(ch);
              if(n === -1){//why does it always resolve to true            
                  flag = true;
                  break;
              }
              else{
  
              }
          }
          if(flag){
              alert("Not a number");
              $('#empcontact').val(" ");
              $('#empcontact').focus();
          }
  });
  </code></pre>
  
  <p>I don't know why it always resolves to true even when numbers are passed also when characters are passed.</p>