Date picker required doesn’t work in Contact Form 7


Date picker required doesn’t work in Contact Form 7

You need to edit core plugin files before that you need to save contact-form-7-datepicker folder for backup

You go to  wp-content/plugins/contact-form-7-datepicker/modules/date.php

Normal Code (Line Number :124)


if ('datetime*' == $type && empty($value)) {
    $result['valid'] = false;
    $result['reason'][$name] = wpcf7_get_message('invalid_required');
}
if (! empty($value) && ! self::is_valid_date($value)) {
    $result['valid'] = false;
    $result['reason'][$name] = wpcf7_get_message('invalid_datetime');
}

Change to below code

if ('date*' == $type && empty($value)) {
    $result['valid'] = false;
    $result['reason'] = array($name => wpcf7_get_message('invalid_required'));
}
if (! empty($value) && ! self::is_valid_date($value)) {
    $result['valid'] = false;
    $result['reason'] = array($name => wpcf7_get_message('invalid_datetime'));
}

Then I changed also time.php (from line 119) and datetime.php (from line 119) files in that similar way.
I hope this helps to you

Advertisements