Title: Date / time validation?
Last modified: October 30, 2019

---

# Date / time validation?

 *  Resolved [WebBuddy](https://wordpress.org/support/users/websprout/)
 * (@websprout)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/date-time-validation/)
 * Hi,
 * First, thank you for this great plugin!
 * Next, I am having two fields (Start Time & End Time) in my contact form. Is it
   possible for this plugin to detect if the user selects a End Time earlier than
   Start Time, then it prompts an error?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Carlos Moreira](https://wordpress.org/support/users/carlosmoreirapt/)
 * (@carlosmoreirapt)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/date-time-validation/#post-12081279)
 * Hi [@websprout](https://wordpress.org/support/users/websprout/) unfortunately
   this is not possible in the current version of the plugin. Sorry for this limitation.
 *  Thread Starter [WebBuddy](https://wordpress.org/support/users/websprout/)
 * (@websprout)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/date-time-validation/#post-12090221)
 * Thank you for your reply, Carlos.
 * I managed to find a custom validation article on contact form 7 and it teaches
   me to code the following to check if end date is earlier than the start date.
   Just posting here in case in future others may need it:
 *     ```
       // to check if form end date is earlier than start date
       add_filter( 'wpcf7_validate_text', 'custom_email_confirmation_validation_filter', 20, 2 );
   
       function custom_email_confirmation_validation_filter( $result, $tag ) {
           if ( 'enddate' == $tag->name ) {
   
               $dateTimestamp1 = strtotime($_POST['startdate']); 
               $dateTimestamp2 = strtotime($_POST['enddate']); 
   
               if ( $dateTimestamp1 > $dateTimestamp2) {
                   $result->invalidate( $tag, "End date cannot be earlier than Start date!" );
               }
           }
   
           return $result;
       }
       ```
   
 * The article for reference is at – [https://contactform7.com/2015/03/28/custom-validation/](https://contactform7.com/2015/03/28/custom-validation/)
 *  [Carlos Moreira](https://wordpress.org/support/users/carlosmoreirapt/)
 * (@carlosmoreirapt)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/date-time-validation/#post-12091017)
 * Thank you [@websprout](https://wordpress.org/support/users/websprout/)
    That 
   will be helpful to others for sure. Greetings, Carlos

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Date / time validation?’ is closed to new replies.

 * ![](https://ps.w.org/date-time-picker-field/assets/icon.svg?rev=2964043)
 * [Availability Datepicker – Booking Calendar for Contact Form 7 – Input WP](https://wordpress.org/plugins/date-time-picker-field/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/date-time-picker-field/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/date-time-picker-field/)
 * [Active Topics](https://wordpress.org/support/plugin/date-time-picker-field/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/date-time-picker-field/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/date-time-picker-field/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Carlos Moreira](https://wordpress.org/support/users/carlosmoreirapt/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/date-time-validation/#post-12091017)
 * Status: resolved