Home › Forums › Classic DFFS › Date <= Today
- This topic has 3 replies, 2 voices, and was last updated 3 years, 11 months ago by Alexander Bautz.
-
AuthorPosts
-
-
December 14, 2020 at 20:27 #32241
Hi. I have a date field where I would like to require that users select a date that is less than or equal to today. Is this possible?
I am using Dynamic Forms for SharePoint v4.4.5.13
Thank you.
-
December 14, 2020 at 23:44 #32243
Hi,
You can set up a rule on your date field with the operator “greater than” and value [today]. Also set the Save item button visiblity = Hidden.This way the save button is not visible if the user haven’t selected the proper date value.
There are other options using Custom JS also, but try this one first.
Alexander
-
December 15, 2020 at 14:37 #32245
Thank you. The [today] piece worked great for the expression. I tried setting the save button to not be visible but a couple things happen:
– If the date is entered in the future, and then changed to be in the past, the save button is visible again BUT it is grayed out/disabled.
– The save button in the ribbon is still visible and when clicked, the behavior now downloads the document instead of saving the item.
– Since it’s not checking the date field until after you exit the field, this could also be an issue for what I’m trying to do since they could enter the date and click Save right away.I tried this on Edge, Chrome and Internet Explorer with the same results.
-
December 15, 2020 at 16:50 #32247
I did a quick test and noticed a bug with hiding the save button in the ribbon in a document library – not sure if this is something new in SPO or a bug that has slipped past me for a long time, but I’ll get this fixed in the next release.
I’m not able to reproduce the disabled button, but the download of the document is caused by NOT having the a “RootFolder” or “Source” parameter in the URL query string. If you exit directly from the DFFS configuration to EditForm you might get this behavior.
Clicking directly from the datepicker to the save button should not let the user save, but you can try using this Custom JS approach instead (remove the rules – this only uses custom js).
function dffs_PreSaveAction() { var date = spjs.utility.getDateFieldAsDateObject("DateField"); date.setHours(12, 0, 0, 0); var today = new Date(); today.setHours(12, 0, 0, 0); if (date > today) { spjs.modal.add({ "title": "Wrong date selected", "html": "You must select a date that is less than or equal to today.", "allowMaximize": false, "resizable": false, "ok": function() { // Close dlg } }); return false; } return true; }
Replace “DateField” with your date picker internal name.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.