title: Strange jquery bug in simple code
body: <p>I have a simple html code with form:</p>
  
  <pre><code>&lt;span class="price"&gt;&lt;/span&gt;
  Enter amount: 
  &lt;input type="text" class="form-control amount" name="amount" value="500"&gt;
  
  &lt;!--Next input fields are hidden by Bootstrap class "hide"--&gt;
  &lt;input type="text" name="minimal-amount" class="hide minimal-amount" value="500"&gt;
  &lt;input type="text" name="oneprice" class="hide oneprice" value="0.20"&gt;
  
  &lt;script&gt;
  $(".amount").on("change", function(){
          var am = $(".amount").val();
          var min = $(".minimal-amount").val()
          if(am&lt;min){
              $(".amount").val($(".minimal-amount").val());
          }else{
              var am = $(".amount").val();
              var oneP = $(".oneprice").val();
              var finalPrice = am*oneP;
              $(".price").html(finalPrice);       
          }
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>Idea of this code is very simple. When user put in <code>amount</code> field digits, my script should check, if that, what user put is smaller than minimum available value in <code>minimal-amount</code> field, script changes value of <code>amount</code> field to default <code>minimal-amount</code>.
  But the problem is, that id I just add <code>0</code> in <code>amount</code> field (and it's value become 5000) everything is ok, but when I changes value of <code>amount</code> field to 1000, script changes value of <code>amount</code> field to default, as if it smaller them <code>minimul-amount</code>.
  What I do wrong, and how can I fix this problem?
  P.S. Example of this code you can find here - <a href="http://friendfi.me/tests/amount.php" rel="nofollow">http://friendfi.me/tests/amount.php</a></p>