- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 01:38 PM
I am in need of a way to have them select a date but they are only allowed to select the first day of a pay period. So pretty much I need to display every other Sunday.
Should I use a date field? Should I populate a select box? What's the best way to approach this?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 02:16 PM
Got it ! Below 👇 script should work
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') return;
var selectedDate = new Date(newValue);
var day = selectedDate.getDay(); // 0 = Sunday
if (day !== 0) {
g_form.showFieldMsg('your_date_field', 'Please select a Sunday.', 'error');
g_form.setValue('your_date_field', '');
return;
}
// Base Sunday: April 6, 2025
var baseSunday = new Date('2025-04-06');
var diffTime = selectedDate.getTime() - baseSunday.getTime();
var diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (diffDays % 14 !== 0 || diffDays < 0) {
g_form.showFieldMsg('your_date_field', 'Please select an alternate Sunday starting from April 6, 2025.', 'error');
g_form.setValue('your_date_field', '');
} else {
g_form.hideFieldMsg('your_date_field', true);
}
}
Please change the field names accordingly.
I tried with - 2025-04-13 - didn't accept
2025-04-27 - didn't accept
2025-05-18 - accepted.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 02:11 PM
We could start with 4/6/25 and then every two weeks after that.
4/6/25
4/20/25
5/4/25
5/18/25
etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 02:16 PM
Got it ! Below 👇 script should work
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') return;
var selectedDate = new Date(newValue);
var day = selectedDate.getDay(); // 0 = Sunday
if (day !== 0) {
g_form.showFieldMsg('your_date_field', 'Please select a Sunday.', 'error');
g_form.setValue('your_date_field', '');
return;
}
// Base Sunday: April 6, 2025
var baseSunday = new Date('2025-04-06');
var diffTime = selectedDate.getTime() - baseSunday.getTime();
var diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (diffDays % 14 !== 0 || diffDays < 0) {
g_form.showFieldMsg('your_date_field', 'Please select an alternate Sunday starting from April 6, 2025.', 'error');
g_form.setValue('your_date_field', '');
} else {
g_form.hideFieldMsg('your_date_field', true);
}
}
Please change the field names accordingly.
I tried with - 2025-04-13 - didn't accept
2025-04-27 - didn't accept
2025-05-18 - accepted.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 02:50 PM
I like it! Thanks!