Support

Account

Home Forums Backend Issues (wp-admin) Restrict datepicker ending date by starting date Reply To: Restrict datepicker ending date by starting date

  • Hi
    this is the code that i used:
    (function($) {
    $(‘#firstdate .acf-date-picker input.hasDatepicker’).live(“change”, function(e) {
    var getval = $(this).val();
    var dataname = $(“#firstdate”).attr(“data-name”);
    if (dataname == “fecha_de_llegada”) {
    var makedate = $(this).val().split(“/”);
    var date = new Date(makedate[1] + “/” + makedate[0] + “/” + makedate[2]);
    date.setDate(date.getDate() + 1);
    if (!isNaN(date.getTime())) {
    var getnew = date.toLocaleDateString(‘en-GB’);
    var getmyd = getnew.split(‘/’);
    var gyear = getmyd[2].toString();
    var gmonth = getmyd[1].toString();
    var gday = getmyd[0].toString();
    $(“#seconddate”).find(‘input[type=text]’).val(date.toLocaleDateString(‘en-GB’));
    $(“#seconddate”).find(‘input[type=hidden]’).val(gyear+gmonth+gday);
    } else {
    alert(“Invalid Date”);
    }
    }
    });
    })(jQuery);

    make sure that you change the ID/classes of you element:
    #firstdate, #seconddate

    hope it helps