Copy link to clipboard
Copied
Hi, I have a pdf form in which I have two dates fields side by side. I would like to know if we can block some months in the calendar so people cannot choose these dates in the first date field. In the second field there is already this custom calculation script :
var cDate = this.getField("DateField3").value;
if (cDate) {
var d1 = new Date();
d1 = util.scand("dd/mm/yyyy", cDate);
d1.setDate(d1.getDate() - 1) + d1.setFullYear(d1.getFullYear() + Number(this.getField("Dropdown44").valueAsString));
event.value = util.printd("dd/mm/yyyy", d1);
}
It's not related but I guess it add a specificity to the code for the first box to block months in the calendar. What is the code for this ?
Let's say you want to 'block' 5th and 6th months (May, June), use this as 'Validate' script of that field:
var dateStr = event.value;
if (dateStr) {
var dateParts = dateStr.split("/");
var month = parseInt(dateParts[1], 10);
if (month === 5 || month === 6) {
app.alert("Dates in May and June are not allowed.");
event.rc = false;}}
This will work for format "dd/mm/yyyy".
Copy link to clipboard
Copied
Let's say you want to 'block' 5th and 6th months (May, June), use this as 'Validate' script of that field:
var dateStr = event.value;
if (dateStr) {
var dateParts = dateStr.split("/");
var month = parseInt(dateParts[1], 10);
if (month === 5 || month === 6) {
app.alert("Dates in May and June are not allowed.");
event.rc = false;}}
This will work for format "dd/mm/yyyy".
Copy link to clipboard
Copied
Thank you, it works perfectly.