Hi Daniel,
I tried to format the “to” date in dependence of the from date field. Therefore I used the “minDate” option from the date picker options and hoped that I could get and set the date from the “from” field as a new date in the value field.
I think this can be done only with custom JavaScript.
Here are some steps that I'm thinking:
First, add the following code to functions.php
file, this code enqueues a custom JS file:
add_action( 'rwmb_enqueue_scripts', function() {
wp_enqueue_script( 'custom-code', get_template_directory_uri() . '/custom.js', ['jquery'], '', true );
} );
Second, create a file custom.js
and put it in your theme. And put the following code in that file:
$from = $( '#from' );
$to = $( '#to' );
$from.on( 'change', function() {
$to.datepicker( "option", "minDate", $from.val() );
} );
Here I assume your fields has ID from
and to
. You might want to change it to something else if you have different IDs.