Add the following code to the theme functions.php file (or create a plugin for it). The code requires PHP 5.3 or later.
12
3
4
5
6
7
8
9
10
11
12
| add_filter('quform_element_valid_1_3', function ($valid, $value, $element) { if ($valid) { $age = date_diff(date_create($value), date_create('now'))->y; if ($age < 18) { $element->addError('You must be 18 or older to continue'); $valid = false; } } return $valid; }, 10, 3); |
add_filter('quform_element_valid_1_3', function ($valid, $value, $element) { if ($valid) { $age = date_diff(date_create($value), date_create('now'))->y; if ($age < 18) { $element->addError('You must be 18 or older to continue'); $valid = false; } } return $valid; }, 10, 3);
- On line 1, replace
1_3
with the Date element unique ID