function wpcf7_date_validation_filter($result, $tag) { $tag = new WPCF7_Shortcode($tag); $name = $tag->name; $min = $tag->get_date_option('min'); $max = $tag->get_date_option('max'); $value = isset($_POST[$name]) ? trim(strtr((string) $_POST[$name], "\n", " ")) : ''; if ($tag->is_required() && '' == $value) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_required'); } elseif ('' != $value && !wpcf7_is_date($value)) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_date'); } elseif ('' != $value && !empty($min) && $value < $min) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('date_too_early'); } elseif ('' != $value && !empty($max) && $max < $value) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('date_too_late'); } if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) { $result['idref'][$name] = $id; } return $result; }
function wpcf7_date_validation_filter($result, $tag) { $tag = new WPCF7_FormTag($tag); $name = $tag->name; $min = $tag->get_date_option('min'); $max = $tag->get_date_option('max'); $value = isset($_POST[$name]) ? trim(strtr((string) $_POST[$name], "\n", " ")) : ''; if ($tag->is_required() && '' == $value) { $result->invalidate($tag, wpcf7_get_message('invalid_required')); } elseif ('' != $value && !wpcf7_is_date($value)) { $result->invalidate($tag, wpcf7_get_message('invalid_date')); } elseif ('' != $value && !empty($min) && $value < $min) { $result->invalidate($tag, wpcf7_get_message('date_too_early')); } elseif ('' != $value && !empty($max) && $max < $value) { $result->invalidate($tag, wpcf7_get_message('date_too_late')); } return $result; }