In Forms 9.1 is there a way to have the form not be submittable after a specific date?
Question
Question
Cut-off date for a form to be submitted.
Answers
There are a few ways you can handle this:
- Manually hide the business process on the date.
- Use JavaScript to disable the submit button if the date after the specified date.
The JavaScript way is pretty simple. I'll use a library called moment.js. Download that (get moment.min.js) and put it in this folder on your Forms Server: C:\Program Files\Laserfiche\Laserfiche Forms\Forms\js.
On the CSS and JavaScript page for your form, paste the following code in the JavaScript section, replacing FormsServer with the name of your Forms Server machine.
$(document).ready(function () { $.getScript('http://FormsServer/Forms/js/moment.min.js', function () { if (moment().isAfter(moment('02-20-1973', 'MM-DD-YYYY'))) { $('.Submit').attr('disabled','disabled'); } }); });
You could also have a message appear to let the user know that the form can't be submitted anymore.
Eric,
I'm able to get this to work with the date you have entered but I cannot get this to work for me with another date. I've attached the code I am using. Please let me know where I'm going wrong. Thanks
$(document).ready(function () { $.getScript('http://L7711/Forms/js/moment.min.js', function () { if (moment().isAfter(moment("Feb 20, 2020"))); { $('.Submit').attr('disabled','disabled'); } else { $('.Submit').removeAttr('disabled'); } }); });
Hi Nathan,
It looks like that code wasn't quite working! I changed it slightly to use a different format and it looks like it's working now. (I'll update it now) Try this:
$(document).ready(function () { $.getScript('http://L7711/Forms/js/moment.min.js', function () { if (moment().isAfter(moment('02-20-2020', 'MM-DD-YYYY'))) { $('.Submit').attr('disabled','disabled'); } else { $('.Submit').removeAttr('disabled'); } }); });
Hi Nathan,
It looks like that code wasn't quite working! I changed it slightly to use a different format and it looks like it's working now. (I'll update it now) Try this:
$(document).ready(function () { $.getScript('http://L7711/Forms/js/moment.min.js', function () { if (moment().isAfter(moment('02-20-2020', 'MM-DD-YYYY'))) { $('.Submit').attr('disabled','disabled'); } else { $('.Submit').removeAttr('disabled'); } }); });