Support » Plugin: Date Time Picker Field » Date / time validation?

  • Resolved websprout



    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)
  • Plugin Author Carlos Moreira


    Hi @websprout unfortunately this is not possible in the current version of the plugin. Sorry for this limitation.

    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 –

    Plugin Author Carlos Moreira


    Thank you @websprout
    That will be helpful to others for sure.
    Greetings, Carlos

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.