Join the Team Forms community

Members
Dan
D
Dan
Offline, last seen 4 months ago
Joined September 4, 2024

In this use case, there is a start date, end date, and a goaled number value (must be greater than 0). if the goal value (quotaGoal) is left blank, no validation is needed. if the goal is >0, then the start date (startQuota) must be set to the 1st of the month selected by the user and the end date (endQuota) must be set to the last day of the month.


I have come up with the below validation statements to handle the 1st/last day of the month, but am stuck on how to connect them with value the goaled number field.


Start Date must be 1st of month

JavaScript
const date = moment(data.startQuota);
const isFirstDayOfMonth = date.isSame(date.clone().startOf('month'), 'day');
valid = isFirstDayOfMonth

End Date must be last date of month

JavaScript
const date = moment(data.endQuota);
const isLastDayOfMonth = date.isSame(date.clone().endOf('month'), 'day');
valid = isLastDayOfMonth


Thanks for any help!


2 comments
E
D