I have created the following custom field
return sprintf(
$html = '<input id="' . $targetName .'-' . $fieldType . '" type="text" name="%s" title="' . $field['field_name'] . '" value=" ' . $meta . '">
<script>
document.addEventListener("DOMContentLoaded", function(event) {
const fp = flatpickr("#' . $targetName .'-' . $fieldType . '",
{
dateFormat: "Y-m-d H:i"
});
})
</script>
',
$field['field_name'],
$meta
);
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?
https://docs.metabox.io/validation/
[
'type' => 'dc_date_picker_calendar',
'name' => 'End Date',
'id' => 'end_date',
'class' => 'dc-start-date',
'required' => true,
],
Thanks