Support

Account

Home Forums Front-end Issues Set minDate (and other options) of date_pickers

Unread

Set minDate (and other options) of date_pickers

  • I”m trying to set the minDate of two fields, Start and End dates, as well as update the End date when the Start date changes. My code should work, but clearly, I am missing something. Any keen eyes would be appreciated.

    This code is on the template page where my acf_form is instantiated:

    <script type="text/javascript">
    	$( document ).ready( function () ) {
    
    		// Set Audition-End-Date (466) initial minDate option
    		$( "td.acf-field_59bae78451466 > div.acf-input > div.acf-date_picker > input.hasDatepicker" ).datepicker( {
    			minDate: new Date( '+8d' )
    		} );
    
    		// Set Audition-Start-Date (465) initial minDate option and End-date updater
    		$( "td.acf-field_59bae74851465 > div.acf-input > div.acf-date_picker > input.hasDatepicker" ).datepicker( {
    			minDate: new Date( '+8d' ),
    			onSelect: function () {
    				var strdate = $( this ).datepicker( 'getDate' );
    				var enddate = $( "td.acf-field_59bae78451466 > div.acf-input > div.acf-date_picker > input.hasDatepicker" ).datepicker( 'getDate' );
    				if ( enddate < strdate ) {
    					$( "td.acf-field_59bae78451466 > div.acf-input > div.acf-date_picker > input.hasDatepicker" ).datepicker( "option", "minDate", new Date( strdate ) );
    				}
    			}
    		} );
    	};
    </script>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.