Need Help with Checkout Page Custom Field Javascript

RobertRobert Member
in Help edited April 2013
My client would like a very specific feature for the checkout page. I need an HTML Select tag drop down menu that the user has to choose an item from the drop down in order to checkout successfully. I found this page about adding custom fields (http://wiki.foxycart.com/v/1.1/checkout), but I need help with the javascript code that would make this possible.

Menu:
Sidebar Description: Would you like to subscribe to the newsletter?
1. (Default State) -Select-
2. Yes, please sign me up
3. No
4. I am already subscribed.

I need to create the javascript that would throw a soft error or just doesn't validate if they don't select one of the options in the menu. I am not very good at javascript so any help would be really appreciated!

Thanks!
Rob
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @Robert,

    Actually, you don't need any javascript at all - the checkout has some validation logic in there - and you can create your dropdown to be required as part of that. You just need to give it a class of "fc_required" and include an error label for it as well. Something like this should work:
    <label for="newsletter" class="fc_pre">Would you like to subscribe to the newsletter?<span class="fc_ast">*</span></label>
    <select name="newsletter" id="newsletter" class="fc_required">
      <option value="">- Select -</option>
      <option value="Yes">Yes, please sign me up</option>
    </select>
    <label for="newsletter" class="fc_error" style="display:none;">Please select an option.</label>
    
  • Thanks fc_adam. So much more simple than I thought. Thanks for the quick response!
Sign In or Register to comment.