title: How to compare two input values onkey jquery
body: <p>I have a form with two input fields.</p>
  
  <pre><code>&lt;input type="text" id="first" value=""&gt;
  &lt;input type="text" id="second" value=""&gt;
  </code></pre>
  
  <p>I have tried this but no success</p>
  
  <pre><code>&lt;script&gt;
  $(function(){
      var fst=$("#first").val();
      var sec=$("#second").val();
      if (sec&gt;fst) {
          alert("Second value should less than first value");
          return true;
      }
  })
  &lt;/script&gt;
  </code></pre>
  
  <p>How to allow only second input values are only numbers and also less than the first input</p>