You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Dynamically disable a Form at a specific date/time

posted on June 30, 2021

Is there anything within Laserfiche Rio 10.4 that I can use to disable a LF Form at a specific date or time?  I have a few forms that are only supposed to be available from start date to an end date and I am off when on the end date.

Thanks smiley

0 0
replied on June 30, 2021

Thanks Stephen!  Understand about the client's device current date.  Appreciate it!!  Have a great day and thanks again!!

0 0
replied on June 30, 2021 Show version history

While it would be better to manually unpublish the form or to add a Custom HTML explaining that form submissions will not be accepted before/after a certain time, it's possible to use the following JavaScript to essentially scrub the form of all content if today's date is not between a defined start and end date:

 

$(document).ready(function(){
  
    // The start date (July 1, 2021) in YYYY-MM-DD format
    var startDate = new Date('2021-07-01');
      
    // The end date (July 31, 2021) in YYYY-MM-DD format
    var endDate = new Date('2021-07-31');
    
    // Today's date
    var today = new Date();
  
    // If today is before the start date, replace the form's content with a message.
    if (today < startDate){
      document.body.innerHTML = "<p>This form will become available on July 1, 2021.</p>";          
    }
    
    // If today has passed the end date, replace the form's content with a message.
    if (today >=endDate){
      document.body.innerHTML = "<p>This form is now closed.</p>";          
    }
}); 

 

Some caveats here is that JavaScript uses the client's machine for the current date. So if they could feasibly change their device's date setting to circumvent it. 

2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.