There is a date control in the requirement. The expected date of delivery can only be selected today and within 16 weeks in the future, so a verification is needed. The following is a piece of JS to get the specified date in the future
Get the future Specify the date YYYY-MM-DD n represents the number of days, such as 16 weeks, you need to convert the turnover into days before passing it in.
function getFutureDate(n) { var n = n; var d = new Date(); var year = d.getFullYear(); var mon = d.getMonth() + 1; var day = d.getDate(); if(day > n) { if(mon > 1) { mon = mon + 1; } else { year = year + 1; mon = 12; } } d.setDate(d.getDate() + n); year = d.getFullYear(); mon = d.getMonth() + 1; day = d.getDate(); s = year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day); return s; }
For more related tutorials, please visit JavaScript video tutorial