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);