title: How to check the function's return value if true or false
body: <p>I have a function here that validate fields in a form if they are empty.</p>
  
  <pre><code>function ValidateForm()
  {
      jQuery('span.error_msg').hide();
     var success = true;
      jQuery("#shippingF input").each(function()
          {
              if(jQuery(this).val()=="")
              {
                  jQuery(this).next().show();
                  success = false;
              }
      });
      return success;
  }
  </code></pre>
  
  <p>Now I wanted to use that function here:</p>
  
  <pre><code>function post(url,formId) {
        jQuery("#process").html('&lt;img src="&lt;?php echo get_bloginfo('wpurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/images/co/ajax-loader.gif'; ?&gt;" alt="loading" title="ajax-loader" width="16" height="16" class="alignnone size-full wp-image-134"&gt;');
       jQuery.post(url, jQuery('#' + formId).serialize(), function(d) {
          jQuery('html,body').animate({scrollTop: jQuery("#scrollhere").offset().top},'slow');
          jQuery("#response").html('&lt;center&gt;&lt;p style="height:820px"&gt;&lt;span style="color:black;font-weight:bold;font: 11px arial,verdana,sans-serif;"&gt;&lt;b&gt;Loading available payment getaways..&lt;/b&gt;&lt;/span&gt;&lt;br/&gt;&lt;img src="&lt;?php echo get_bloginfo('wpurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/images/co/8-1.gif'; ?&gt;" width="220" height="19" /&gt;&lt;/p&gt;&lt;/center&gt;');
          jQuery("#response").load("&lt;?php echo get_bloginfo('wpurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/checkout_payment.php'; ?&gt;", function() { Cufon.refresh(); });
          jQuery("#response").attr("style","height:1030px");
      });
  }
  </code></pre>
  
  <p>I tried it and I come up with this.</p>
  
  <pre><code>function post(url,formId) {
   ValidateForm();
   if(ValidateForm() == 'false') {
     jQuery('html,body').animate({scrollTop: jQuery("#shippingF").offset().top},'slow');
   } else {
        jQuery("#process").html('&lt;img src="&lt;?php echo get_bloginfo('wpurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/images/co/ajax-loader.gif'; ?&gt;" alt="loading" title="ajax-loader" width="16" height="16" class="alignnone size-full wp-image-134"&gt;');
       jQuery.post(url, jQuery('#' + formId).serialize(), function(d) {
          jQuery('html,body').animate({scrollTop: jQuery("#scrollhere").offset().top},'slow');
          jQuery("#response").html('&lt;center&gt;&lt;p style="height:820px"&gt;&lt;span style="color:black;font-weight:bold;font: 11px arial,verdana,sans-serif;"&gt;&lt;b&gt;Loading available payment getaways..&lt;/b&gt;&lt;/span&gt;&lt;br/&gt;&lt;img src="&lt;?php echo get_bloginfo('wpurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/images/co/8-1.gif'; ?&gt;" width="220" height="19" /&gt;&lt;/p&gt;&lt;/center&gt;');
          jQuery("#response").load("&lt;?php echo get_bloginfo('wpurl').'/wp-content/plugins/'.basename(dirname(__FILE__)).'/checkout_payment.php'; ?&gt;", function() { Cufon.refresh(); });
          jQuery("#response").attr("style","height:1030px");
      });
   }
  }
  </code></pre>
  
  <p>The problem is that, the validation is working.. however, <code>.post()</code> function runs even though there is empty field. I guess its on the if/else condition.. is there a better way to accomplish this?</p>
  
  <p>Thank you.</p>