How can I restrict Two dates in ACF date picker for Starting date and Ending Date in Wordpress? How can I restrict Two dates in ACF date picker for Starting date and Ending Date in Wordpress? wordpress wordpress

How can I restrict Two dates in ACF date picker for Starting date and Ending Date in Wordpress?


I think there is no possibilities for date restriction in acf in admin area.

I may be done in acf's newer version.

You can request from here...

http://support.advancedcustomfields.com/forums/forum/feature-requests/


I think we can do it with java script and use this code to set the limit of the end date :

$( ".selector" ).datepicker({  minDate: new Date(  )});


I had similar problem with regular date fields, Hope this JS code (with the moment JS library) with some adjustments will help you.

$(document).ready(function() {   $("input[name='Arrival']").change(function() {      var date_picked = $("input[name='Arrival']").val();      var SpecialTo = moment(date_picked, "YYYY-MM-DD");      var today = new Date();      today.setDate(today.getDate() - 240);      var selectedDate = new Date(date_picked);      if (today <= selectedDate) {         //alert('Date is today or in future');      } else {         alert('Date is in the past');         $("input[name='Arrival']").val('');      }  });}) 

If you could post the source HTML of the date input with a value, I could change it probably to what you looking for.