Custom Fields
Support MB Frontend Submission Custom Field and Form Validation

  • Creator
  • #33027
    Nicholas Cox

    I have created the following custom field

    return sprintf(
    $html = '<input id="' . $targetName .'-' . $fieldType . '" type="text" name="%s" title="' . $field['field_name'] . '" value=" ' . $meta . '">
            document.addEventListener("DOMContentLoaded", function(event) {
                const fp = flatpickr("#' . $targetName .'-' . $fieldType . '", 
                    dateFormat: "Y-m-d H:i"


    I want to add validation to this and after reading the docs in confused as to how I can make this work with the above hidden input field? basically Flatpickr hides the input field and then uses a html overlay to choose a date. I assume I need to validate e.g. YYYY-MM-DD? or can i just check there value is not null?

        'type'      => 'dc_date_picker_calendar',
        'name'      => 'End Date', 
        'id'        => 'end_date',
        'class'     => 'dc-start-date',
        'required'  =>  true,


Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #33033
    Long Nguyen


    The hidden field is ignored to validate, it is updated from this commit

    You can create your own JS code to check the empty field value, refer to this topic

    Nicholas Cox

    Hi Long,

    I am note sure how to go about this using the topic link provided to work with Metabox.

    Just thinking about the 'required' field setting in Metabox. Surely if we specify a hidden field to be 'required' then the jQuery validation could honour it?

        'id'   => 'field_id',
        'type' => 'hidden',
        'required' => true,

    Sorry if I'm missing the point but to ignore all hidden fields surely it will not be great for development purposes?


Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.