asked on September 9, 2022
Dear All
I am looking for a solution where the due date should be shown after number of days , means I have four categories of task each task is required 3 , 7, 15,21 days when requester select the task due date needs to hide previous dates and weekends based on task duration dates, also requester cannot choose weekends , can I have java script for the same , I got java script from this site which is working , but only for one type of calculation , when I do the JS for other due date fields the weekends are enabling . I am attaching the Javascript i have , in my understanding i need to create 3 more clasess and assign to each due date fields, Can any one help, Attaching the JS which I have .
(function () { var moment; moment = (typeof require !== "undefined" && require !== null) && !require.amd ? require("moment") : this.moment; moment.fn.businessAdd = function (days) { var signal = days<0?-1:1; days = Math.abs(days); var d = this.clone().add(Math.floor(days / 5) * 7 * signal, 'd'); var remaining = days % 5; while(remaining){ d.add(signal, 'd'); if(d.day() !== 0 && d.day() !== 5) remaining--; } return d; }; }).call(this); $(document).ready(function(){ //Exclude weekend in date picker function isCorrectDate(n) { var t = new Date(n).getDay(); return (t!=5 && t!=6); } function checkDate(n) { return[isCorrectDate(n),""]; } function checkField(input, inst) { if ($(input).closest('li').hasClass('myDate7')) { $(input).datepicker("option", {beforeShowDay: checkDate}); } } $.datepicker.setDefaults( {beforeShow: checkField} ); //Minimum 7 business days in advance var date = moment().businessAdd(7); $('.myDate7 input').attr('min', date.format('YYYY-MM-DD')); //Validation for exclude weekend, for Forms 10.1 $.webshims.ready('form-validators', function () { $.webshims.addCustomValidityRule('myDate7', function (elem, value) { if (value && $(elem).closest('li').hasClass('myDate7')) { return !isCorrectDate(value); } return false; }, 'Not valid date.'); }); }); $(document).ready(function(){ //Exclude weekend in date picker function isCorrectDate(n) { var t = new Date(n).getDay(); return (t!=5 && t!=6); } function checkDate(n) { return[isCorrectDate(n),""]; } function checkField(input, inst) { if ($(input).closest('li').hasClass('myDate')) { $(input).datepicker("option", {beforeShowDay: checkDate}); } } $.datepicker.setDefaults( {beforeShow: checkField} ); //Minimum 3 business days in advance var date = moment().businessAdd(3); $('.myDate input').attr('min', date.format('YYYY-MM-DD')); //Validation for exclude weekend, for Forms 10.1 $.webshims.ready('form-validators', function () { $.webshims.addCustomValidityRule('myDate', function (elem, value) { if (value && $(elem).closest('li').hasClass('myDate')) { return !isCorrectDate(value); } return false; }, 'Not valid date.'); }); });
0
0