i did resolved it. Now user can not choose the start date greater than end date. I simply add a function in my functions.php file.
// Date Picker Validation --- Start Date should be less than End Date.
add_action('acf/validate_save_post', 'my_acf_validate_save_post', 10, 0);
function my_acf_validate_save_post()
{
$start = $_POST['acf']['key of datepicker 1'];
$start = new DateTime($start);
$end = $_POST['acf']['key of datepicker 2'];
$end = new DateTime($end);
// check custom $_POST data
if ($start > $end) {
acf_add_validation_error('name of datepicker field you want to display error message. ', 'End Date should be greater than or Equal to Start Date');
}
}
In this i have select two datepicker and then converted them to date format then compared them as you can see above.
* You can get key of ACF field from sreen option and then selecting field keys
* You can select the name of the field by inspecting in chrome and selecting the datepicker input field.
I have the same issue, but i did resolved it. Now user can not choose the start date greater than end date. I simply add a function in my functions.php file.
// Date Picker Validation --- Start Date should be less than End Date.
add_action('acf/validate_save_post', 'my_acf_validate_save_post', 10, 0);
function my_acf_validate_save_post()
{
$start = $_POST['acf']['key of datepicker 1'];
$start = new DateTime($start);
$end = $_POST['acf']['key of datepicker 2'];
$end = new DateTime($end);
// check custom $_POST data
if ($start > $end) {
acf_add_validation_error('name of datepicker field you want to display error message. ', 'End Date should be greater than or Equal to Start Date');
}
}
In this i have select two datepicker and then converted them to date format then compared them as you can see above.
* You can get key of ACF field from sreen option and then selecting field keys
* You can select the name of the field by inspecting in chrome and selecting the datepicker input field.