Why does isNaN not work the second time it is called?
<p>I need to validate various input fields for non numeric characters. I am also using Bootstrap alerts. So I have the code below. It works fine the first time you make an error. You get the BS alert. However, if you put an error into any subsequent inputs the code does not work ie I do not get an alert.I have checked the contents of the two vars qty and quantity and indeed on 2nd passes of the code, they do contain the bad non numerical character. But for some reason isNaN does not see it. What am I doing wrong?   </p>

<pre><code>$(".product_table").on('change', '.edit_quantity',function (){

  var qty = $(this).find('input').val();
  var quantity = $(this).parents(':eq(1)').find('input').filter(".edit_quantity").val();

  console.log('l 117', qty);
  console.log('l 118', quantity);

  if (isNaN(quantity||qty))
  {
      $("#char_error").show();
  }
  else
  {
  //more code goes here//
  }
}
</code></pre>

<p>HTML:</p>

<pre><code> &lt;div id="char_error" class="alert alert-danger"&gt;
    &lt;strong&gt;Error&lt;/strong&gt; You have entered an illegal character in the quantity box, please enter a number.
    &lt;button type="button" class="close" data-dismiss="alert" aria-label="Close"&gt;
        &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
    &lt;/button&gt;
&lt;/div&gt;
</code></pre>

<p>Furthermore, I start my JS file by hiding the <code>&lt;div id="char_error"&gt;</code> This also not ideal has the contents flashes into view and then disappears. </p>