title: AJAX quantity Validation
body: <p>I want to do a quantity validation using Jquery. I want to check for following </p>
  
  <p>1) that the number is a whole number</p>
  
  <p>2) that it not letter</p>
  
  <p>3) that they is not decimal</p>
  
  <p>4) that the max number is 99.</p>
  
  <p><strong>My current Jquery</strong></p>
  
  <pre><code>$(document).ready(function()
  {
      $('#button').click(function()
      {
          var pid = $('#pid').val();
          var length = $('#length').val();
          var Qty = $('#Qty').val(); // this is the quantity
          var Category = $('#Category').val();
          #Qty = preg_replace('#[^0-9]#i', '', $Qty); // filter everything but numbers
          if ($Qty &gt;= 100) { $Qty = 99; }
          if ($Qty &lt; 1) { $Qty = 1; }
          if ($Qty == "") { $Qty = 1; }
  
          $.ajax({
              url: 'cart.php',
              type: 'POST',
  
              data: { pid:pid, length:length, Qty:Qty, Category:Category },
              success: function(data)
              {
  
  
              }
          })
      });
  });
  </code></pre>