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

Question

Question

Disable forms for given time periods

asked on April 5, 2017 Show version history

I have so far only found one person asking something similar and there didn't seem to be a resolution in the question.

https://answers.laserfiche.com/questions/66269/Feature-Request-Schedule-Form-Availability#72062

 

I would like to potentially stop users from being able to fill out a form after 1:00pm. Is there a way to do this within laserfiche  or potentially use some scripting to hide say the submit button/fields after 1:00pm and leave a note.

0 0

Answer

SELECTED ANSWER
replied on April 6, 2017

$(document).ready(function(){
   
  function setcurrenttime ()
  {
      var currentdate=new Date();
      var hours=(currentdate.getHours() < 10? '0' : '') + currentdate.getHours();
      $('#Field7').val(hours);
      var min= (currentdate.getMinutes() < 10? '0' : '') + currentdate.getMinutes();
      $('#Field6').val(min);
      var datetimenow=(hours)+ ":" +min;
      $('#Field1').val(datetimenow);
   }
      setcurrenttime();
});

$(document).ready(function () {
$('.required').on('blur', 'input', isReady);

  function isReady() {
    $('.required input').each(function(){
      
      if($(this).val() > "15:00" ) 
      { 
        alert('Sorry, it is after 3pm');
       $('.Submit').hide()
      }
      else
        {
           $('.Submit').show()
        }
          
});
}
});

0 0

Replies

replied on April 5, 2017

Since this feature is not yet available, you should be able to do it using JavaScript. You could evaluate the current time and if it is equal to or greater than 1:00pm then $submit.hide();.

1 0
replied on April 5, 2017

Anthony

I will post the Java for you. We have implemented that at our client

0 0
SELECTED ANSWER
replied on April 6, 2017

$(document).ready(function(){
   
  function setcurrenttime ()
  {
      var currentdate=new Date();
      var hours=(currentdate.getHours() < 10? '0' : '') + currentdate.getHours();
      $('#Field7').val(hours);
      var min= (currentdate.getMinutes() < 10? '0' : '') + currentdate.getMinutes();
      $('#Field6').val(min);
      var datetimenow=(hours)+ ":" +min;
      $('#Field1').val(datetimenow);
   }
      setcurrenttime();
});

$(document).ready(function () {
$('.required').on('blur', 'input', isReady);

  function isReady() {
    $('.required input').each(function(){
      
      if($(this).val() > "15:00" ) 
      { 
        alert('Sorry, it is after 3pm');
       $('.Submit').hide()
      }
      else
        {
           $('.Submit').show()
        }
          
});
}
});

0 0
replied on April 7, 2017

Thank you so much August, I have just finally got a chance to start working on this again.

0 0
replied on April 11, 2017

I made some changes as I didnt want to display the time, only compare it and fire off if the time was after 1 pm. I also seemed to get some unintended behavior using the time in quotes "13:00". Not sure if this happened to you August.

 

For some reason it was firing the alert and hiding the submit button at 8:30 in the morning when doing the folowing

if (currentTime > "13:00")

 

So I changed the code to the following....

 

var currentTime = new Date();
var triggerHour = new Date();
      triggerHour.setHours(13, 0, 0);


$(document).ready(function(){
  if (currentTime > triggerHour) {
    alert('Sorry, this form cannot be submitted after 1pm');
        $(".Submit").hide();
  }
});
 

 

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

Sign in to reply to this post.