Only allow the first of a month as valid date selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2022 07:54 AM
Dear Community,
I want to restrict the user to be only able to select the 1st of a month with the variable type DATE .
For clarity, this means the user cannot select any other date within September other than September 1st.
I am also open to other suggestions like being able to select another date but the field defaults to the 1st of the month (with a fitting UI message of course.).
Thanks in advance,
Scott
- Labels:
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2022 08:06 AM
Use onChange() Client Script with GlideAjax on your date restrict the value in date field.
Try this in the background script.
var gd = new GlideDate();
gs.info(gd.getDayOfMonthNoTZ());
if(gd.getDayOfMonthNoTZ() > 1)
gs.print('Only 1st date of month is allowed.');
else
gs.print('Date is correct.');
For Scoped Application, see the below image for reference.
For Global Scope Application, see the below image for reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2022 08:12 AM
Calculate first date of current month
var gdt = new GlideDateTime();
var dt= gs.beginningOfThisMonth(gdt);
gs.print(dt);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2022 08:18 AM
Hi
in my opinion it is a bad user experience if the user is allowed to select only one day and it also causes some efforts which have the touch of a workaround.
Why don't you offer the user a selection of month names and set the date internally to the first day of the selected month? This makes more sense to me from the user's perspective.
Maik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 02:00 AM
Totally with you and the proposal of an alternative to the calendar had already been posed to the PO. Here exploring my options though.
Thanks for the input. Much appreciated.