title: Stopping Jquery displaying an img if the validation isn't passed with PHP or Jquery
body: <p>Ok, so I created an ajax add to cart with Jquery. Basically on click of a button the data is passed to a php page, using jquery and then returns data which is turned into variables and the item is added to the cart, the cart is popped up and a 'item added to cart' image is displayed as confirmation. Anyway... this all works perfectly. </p>
  
  <p>This is my Jquery Code:</p>
  
  <pre><code>$(document).ready(function(){
  
      $("#qtyform").validationEngine({promptPosition : "topLeft:0,15", scroll: false});
      //Examples of how to assign the ColorBox event to elements
  
      $("#cartbtn").click(function () {
          //$('.addcartform').submit();
          $("#cbox").stop(true,false).animate({right:  0}, 500);
          Qty=document.qtyform.Qty.value;
          ProductID=document.qtyform.ProductID.value;
          CatID=document.qtyform.CatID.value;
          Price=document.qtyform.Price.value;
          &lt;?php if(isset($_GET['cart'])) {?&gt;
          itemid=document.qtyform.itemid.value;
          &lt;?php }elseif(isset($_GET['del'])){ ?&gt; 
          itemid2=document.qtyform.itemid2.value;
          &lt;?php } ?&gt;
          //$('#cartresult').load("process.php?Qty="+Qty+"&amp;ProductID="+ProductID+"&amp;CatID="+CatID+"&amp;Price="+Price&lt;?php if(isset($_GET['cart'])) {?&gt;+"&amp;itemid="+itemid&lt;?php }else if (isset($_GET['del'])){ ?&gt;+"&amp;itemid2="+itemid2&lt;?php } ?&gt;);
  
          $.get("process.php?Qty="+Qty+"&amp;ProductID="+ProductID+"&amp;CatID="+CatID+"&amp;Price="+Price&lt;?php if(isset($_GET['cart'])) {?&gt;+"&amp;itemid="+itemid&lt;?php }else if (isset($_GET['del'])){ ?&gt;+"&amp;itemid2="+itemid2&lt;?php } ?&gt;, function(data) {
           //alert("Data = "+data);
           mydata = data; 
           var mytext = mydata.split('#');
  
          var message = mytext[0];
          var linkto = mytext[1];
          var hreftext = mytext[2];
          var finalQty = mytext[3];
  
          $('#cartresult').html('&lt;span style="margin:0px 0px 0px 30px"&gt;&lt;img src="images/ajax-loader-cart.gif" width="24" height="24" alt="" /&gt;&lt;/span&gt;');
  
          document.getElementById('cartresult').innerHTML = '&lt;br /&gt;&lt;a href="'+linkto+'"&gt;'+hreftext+'&lt;/a&gt;';
          document.getElementById('cartnum').innerHTML = finalQty;
  
          });
      });
  });
  </code></pre>
  
  <p>Now the problem is:</p>
  
  <pre><code>$("#qtyform").validationEngine({promptPosition : "topLeft:0,15", scroll: false});
  </code></pre>
  
  <p>The line above using Jquery inline validation to validate a input box for Quantity. If the value entered isn't numeric, it doesn't get added to the cart. This also works, but the added to cart image is still displayed. I would like to stop this. The line for adding the image is this one:</p>
  
  <pre><code>$('#cartresult').html('&lt;span style="margin:0px 0px 0px 30px"&gt;&lt;img src="images/ajax-loader-cart.gif" width="24" height="24" alt="" /&gt;&lt;/span&gt;');
  </code></pre>
  
  <p>Can anyone suggest a way in Jquery or PHP to check if the value entered is numeric, or someway to stop the image being displayed if nothing has been added to the basket. I am fairly new to Jquery but can figure it out, I am stronger with PHP. Thank you in advance.</p>