Required drop-down checkout field

HjaltlandHjaltland Member
in Bugs & Feature Requests edited January 2008
I have a custom checkout field which is a drop-down. Is it possible to make it a required field? And if so, how do you go about it?

Cheers
Comments
  • brettbrett FoxyCart Team
    Hmmm... I'm pretty sure we added select boxes to our validation, but I could be wrong:
    http://wiki.foxycart.com/docs:checkout:customfields#required_fields

    Give that a go. If it doesn't work we'll add it to 0.3.2.
  • Hi Brett,

    Thanks for the reply.

    My coder tried that but didn't have any luck. The is is the relevant part of template - can please have a look and see if we've missed anything obvious.

    Cheers,
    ^^custom_begin^^
     
    <h2>Additional Information</h2>
     
    <fieldset id="fc_custom_fields"><input type="hidden" name="phpMyAdmin" value="fbc82b46d67e062279320c2d5bfa4a74" />
    <legend>Additional Information</legend>
    <div class="fc_inner">
    	  
    <div>
    
    <ul>
    
    <li id="li_property" class="fc_row" STYLE="list-style-type: none;">
    
    <label for="delivery-property" class="fc_labelLeft"><span class="fc_ast">*</span>Property To Be Delivered To:</label>
    
    <select name="delivery-property" style="width: 250px; margin-top: 10px; margin-bottom: 10px; float: right; margin-right: 17px;">
    
    <option value="">Please Select</option>
    
    <option value="Option 1">Option 1</option>
    <option value="Option 2">Option 2</option>
    <option value="Option 3">Option 3</option>
    <option value="Option 4">Option 4</option>
    <option value="Option 5">Option 5</option>
    <option value="Option 6">Option 6</option>
    </select>
    <label for="delivery-property" class="fc_error" style="display:none">Please select a delivery property.</label>
    
    </li>
    
    <li id="li_delivery-date" class="fc_row" STYLE="list-style-type: none;">
    
    <label for="delivery-date" class="fc_labelLeft"><span class="fc_ast">*</span>Delivery Date Required:</label>
    
    <input type="text" name="delivery-date" id="delivery-date" class="text textLong" value="" style="padding: 3px; border: 1px #666666 solid; margin-top: 5px; float: right; width: 120px; margin-right: 17px;" />
    
    <label for="delivery-date" class="fc_error" style="display:none">Please enter a delivery date.</label>
    
    </li>
    
    </ul>
    
    </div>
    </div><!-- .fc_inner -->
    </fieldset><!-- #fc_custom_fields -->
    
     
    ^^custom_end^^
    
    
    <script type="text/javascript" charset="utf-8">
    $j(document).ready(
    	function() {
    		$j("#save_cc").click(
    			function() {
    				this.checked = true;
    			}
    		);
    		$j("#save_cc").get(0).checked = true;
    	}
    );
    </script>
    
    <script type="text/javascript" charset="utf-8">
    /* <![CDATA[ */
    	$j(document).ready(function(){
    	  // add the required class
    	  $j("#customer_phone").addClass("fc_required");
    	  $j("#delivery-property").addClass("fc_required");
    	  $j("#delivery-date").addClass("fc_required");
    	  // add an asterisk to the label
    	  $j("#li_customer_phone label.fc_label_left").append("<span class=\"fc_ast\">*<\/span>");
    	  // add an error label after the phone
    	  $j("#customer_phone").after('<label for="customer_phone" class="fc_error" style="display:none">Please enter your phone number.<\/label>');
     
    	  // Now add the onblur error checking events
    	  $j("#customer_phone").blur(function() {
    	    if (this.value == "") {
    	      fc_UpdateErrorDisplay(this.name,true);
    	    }
    	  });
    	});
    /* ]]> */
    </script>
    
    </body>
    </html>
    
    
  • lukeluke FoxyCart Team
    Required fields need a class of "fc_required" but even then, I'm not sure if they work with select boxes...
  • brettbrett FoxyCart Team
    I'll take a look at our code and see if we can add required functionality to a select box. Shouldn't be hard. (Famous last words. It'll be impossible to find the time, but writing the code won't take all that long.)
  • brettbrett FoxyCart Team
    Added to 0.3.2 as of today. Who knew that the "type" of a select box was actually "select-one" (or "select-multiple")? Not me, apparently.
Sign In or Register to comment.