Support

Account

Home Forums General Issues How to use ACF datepicker for start date less than end date validation Reply To: How to use ACF datepicker for start date less than end date validation

  • Hi @architbjoshi,

    I’m guessing by start date and end date fields you’re referring to two date fields you’ve created.
    Unfortunately there’s no such logic built into ACF.
    Your only option is to insert your own script on your admin page with which you update the datepicker options.

    You can use this filter to add your custom script file:
    http://www.advancedcustomfields.com/resources/acfinputadmin_enqueue_scripts/

    And then you’ll need to check when either start or end date input has been changed and modify the other field accordingly.

    
    //To set a minimum date (back in time)
    jQuery( '.acf-field-UNIQUEID .acf-date_picker input.input' ).datepicker( 'option', 'minDate', date.format() );
    //To set a maximum date (forward in time)
    jQuery( '.acf-field-UNIQUEID .acf-date_picker input.input' ).datepicker( 'option', 'maxDate', date.format() );