type:
snippet
category:
checkout
name:
Making checkout fields required
versions:
0.6.0, 0.7.1, 0.7.2, 1.0
reference:
http://forum.foxycart.com/comments.php?DiscussionID=5077&page=1
date:
2011-12-20

Making checkout fields required

Sometimes as part of the checkout you need to ensure that customers are providing their phone number or company names. To do that, simply paste the following relevant script right before the closing </head> tag of your checkout template.

Making the phone number input required

<script type="text/javascript" charset="utf-8">
  jQuery(document).ready(function(){
    jQuery("#customer_phone").addClass("fc_required");
    jQuery("li.fc_customer_phone label.fc_pre").append("<span class=\"fc_ast\">*<\/span>");
    jQuery("#customer_phone").blur(function() {
    if (this.value == "") {
      FC.checkout.updateErrorDisplay(this.name,true);
    } else {
      FC.checkout.updateErrorDisplay(this.name,false);
    }
   });
});
</script>

Making the company name input required

<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function(){
  jQuery("li.fc_customer_company").children("label.fc_pre").html("Company<span class=\"fc_ast\">*</span>");
  jQuery("#customer_company").addClass("fc_required");
  jQuery("#customer_company").blur(function() {
    if (this.value == "") {
      FC.checkout.updateErrorDisplay(this.name,true);
    } else {
      FC.checkout.updateErrorDisplay(this.name,false);
    }
  });
});
</script>

Site Tools