Custom field for birth date

Hi, i would like to have a costum field for bith date, right below the tax id field, can you send me some sample code?

Also, it should be in this format: DD-MM-YYYY

Thanks
Comments
  • fc_adamfc_adam FoxyCart Team
    @leaodonorte,

    For adding in a custom date field on the checkout, we have a snippet with details on that on our wiki here: https://wiki.foxycart.com/v/2.0/snippets/checkout_custom_datepicker_field.

    As you're wanting it specifically to appear right before the "tax id" field though, those instructions won't completely apply to you. If you complete step 1 on that page in regards to getting the date picker library installed, you can then add the following code to the "footer" textarea of the "Add custom header and footer code to your templates" configuration option:
    {% if context == "checkout" %}
    <script>
    FC.client.on('render.done', function() {
    if ($(".fc-address-entry__birth-date-container").length < 1) {
    var default_value = (FC.json.hasOwnProperty("birth_date")) ? FC.json.birth_date : "";
    $('div.fc-form-group.fc-address-entry__tax-id-container').after('<div class="fc-form-group fc-address-entry__birth-date-container"><label for="birth_date" class="fc-form-label fc-form-label--birth-date col-sm-3">Birth Date</label><div class="col-sm-8"><input type="text" id="birth_date" name="birth_date" value="' + default_value + '" placeholder="Birth Date (optional)" class="fc-form-control fc-form-control--birth-date"></div></div>');

    $("#birth_date").datepicker({
    dateFormat: 'dd-mm-yy',
    onSelect: function() {
    $(this).trigger('focusout.fc', {validateNow: true});
    }
    });
    }
    });
    </script>
    {% endif %}
    I hope that helps!
  • Thanks a lot!
Sign In or Register to comment.