I have 2 date/time fields in a timesheet form. Currently, users can pick any date they want in the first, and the second populates with a date 6 days later. I'm not sure how to validate that the day they pick is a Sunday. Is that possible with scripting??
Thanks in advance,
Rose.
Solved! Go to Solution.
Views
Replies
Total Likes
Views
Replies
Total Likes
Not without scripting .....you can turn the date chosen into a javascript date object and then there is a js function that will return you the day of the week for that particular date.
Paul
Views
Replies
Total Likes
i dont have a huge knowledge of javascript. could you help me with how to do that?
Views
Replies
Total Likes
The attached validates the first date entered is a Sunday and calculates the second date as 6 days from the first date.
// form1.page1.date1::exit - (FormCalc, client)
// Get the number of days since epoch (Jan 1, 1900).
var dateNum = Date2Num($.formattedValue,"MM/DD/YYYY")
// Convert the number of days to the full weekday name.
dayOfWeek.rawValue = Num2Date(dateNum,"EEEE")
// Calculate 6 days from the chosen date by adding 6 to the number of days since the epoch.
date2.rawValue = Num2Date(dateNum+6,"MM/DD/YYYY")
if (dayOfWeek.rawValue ne "Sunday") then
xfa.host.messageBox("Date1 must be a Sunday.");
endif
Steve
Views
Replies
Total Likes
I created a sample for you ...see the attached file.
paul
Views
Replies
Total Likes