Home › Forums › General Issues › Validation between to dates › Reply To: Validation between to dates
Hello, So I have added the following code to my function.php but for some reason iam not getting any validation and the page is just saved no matter what. Any ideas?
function my_acf_validate_save_post()
{
$start = $_POST['field']['field_591a5d2s941df'];
$start = new DateTime($start);
$end = $_POST['field']['field_539a5a2s921d7a'];
$end = new DateTime($end);
// check custom $_POST data
if ($start > $end) {
acf_add_validation_error('late_avail_date_end', 'End Date should be greater than or Equal to Start Date');
}
}
add_action('acf/validate_save_post', 'my_acf_validate_save_post', 10, 0);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.