I added following script to change the date formate of elementor form
<script>
jQuery(document).ready(function () {
setTimeout( function(){
jQuery('.flatpickr-input').each(function(){ flatpickr( jQuery(this)[0] ).set('dateFormat', 'm/d/Y');});
jQuery('.elementor-date-field').removeAttr('pattern');
}, 1000 );
});
</script>
and the following function to restrict the past dates
// Validate the date field min value from today.
add_action( 'elementor_pro/forms/validation/date', function( $field, $record, $ajax_handler ) {
// make sure ts the correct date field
if ( 'YOUR_FIELD_ID' === $field['id'] ) {
return;
}
$min_allowed_date = strtotime( 'today' );
$form_date = strtotime( $field['value'] );
if ( $min_allowed_date > $form_date ) {
$ajax_handler->add_error( $field['id'], 'The Minimum allowed date is, ' . date( 'm/d/Y', $min_allowed_date ) );
}
}, 10, 3 );
it is working only when I logged in as admin. But the javascript is not working when I test from an incognito window like a normal site visiter.
please help me to fix this issue
I changed the javascript to
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
jQuery( document ).ready( function( jQuery ){
setTimeout( function(){
jQuery('.flatpickr-input').each(function(){ flatpickr( $(this)[0] ).set('dateFormat', 'm/d/Y');});
}, 1000 );
});
</script>
Now it is working correctly Thank you