asked on February 20, 2018

Hello All,

I was able to find some Java for the beginning of what I was trying to do, but I need help with the next part. This Form has 2 corresponding Date Picker fields. In the first field, the submitter is only able to select Saturdays (Week Start). In the second field, the submitter is only able to select Fridays (Week End) - currently, the submitter can select any Friday, I would like for it to be only the Friday immediately following the selected Saturday from the first field. 

Then there is a third date picker (Usage Summary - Date) where the submitter can select a day, but it should only be able to show the days in between the 2 selected dates (Saturday and Friday). 

So far, I've gotten JavaScript to only allow Saturdays to be selected in the first field and Fridays selected in the second field. I would like for the Friday to only allow the subsequent Friday and then also the third field to only allow the dates in between those dates to be selected.

The JavaScript I have so far is below which allows Fridays and Saturdays:

$(document).ready(function(){
  function isCorrectDate(n, target) {
    var t = n.getDay();
    return (t==target);
  }
  function checkField(input, inst) {
    if ($(input).closest('li').hasClass('EndFri')) {
      $(input).datepicker("option", {beforeShowDay: function(n) {return [isCorrectDate(n, 5),""]}});
    }
    if ($(input).closest('li').hasClass('StartSat')) {
      $(input).datepicker("option", {beforeShowDay: function(n) {return [isCorrectDate(n, 6),""]}});
  }
  $.datepicker.setDefaults( {beforeShow: checkField} );
  window.Parsley.addValidator('ending', {
    validateString: function(value, target) {
      return isCorrectDate(new Date(value), parseInt(target));
    },
    messages: {
      en: 'Not valid date.'
    }
  });
  $('.EndFri input').attr('data-parsley-ending','5');
  $('.StartSat input').attr('data-parsley-ending','6');
})

 

Any help would be greatly appreciated.

Thanks!

 

Molly

 

0 0