Can you turn off a survey during different times? | Community
Skip to main content
Answered

Can you turn off a survey during different times?


Hi all, is there a way to close a typeform during certain times?  

I want to tell people on a time sensitive survey that they can’t fill out a survey if they are taking it out of hours? 

Thanks! 

Best answer by jeremielp

I think @curiousinengland refers to having the form only active during opening hours not when a business is close. The link you mentioned only allows to close it, but won’t reopen the next day.


There is no native option to do that, but you can embed the Typeform in Javascript, only if the page is loaded while the current time being in the active hours.

Something like this:

<div id="tf"></div>
<link rel="stylesheet" href="//embed.typeform.com/next/css/widget.css" />
<script src="//embed.typeform.com/next/embed.js"></script>
<script>
  function isBusinessHours() {
    var now = new Date();
    var hour = now.getHours();
    return hour >= 9 && hour < 18; // 9 AM to 6 PM
  }

  if (isBusinessHours()) {
    window.tf.createWidget('<form-id>', {
      container: document.getElementById('tf'),
      hidden: { url_form: window.location.href }
    });
  }
</script>

 

View original

2 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 15035 replies
  • January 12, 2024

Yes, it’s possible to close your form, @curiousinengland ! Our article here can walk you through how to do this. 😀


Forum|alt.badge.img+5
  • Community Wizard
  • 127 replies
  • Answer
  • January 16, 2024

I think @curiousinengland refers to having the form only active during opening hours not when a business is close. The link you mentioned only allows to close it, but won’t reopen the next day.


There is no native option to do that, but you can embed the Typeform in Javascript, only if the page is loaded while the current time being in the active hours.

Something like this:

<div id="tf"></div>
<link rel="stylesheet" href="//embed.typeform.com/next/css/widget.css" />
<script src="//embed.typeform.com/next/embed.js"></script>
<script>
  function isBusinessHours() {
    var now = new Date();
    var hour = now.getHours();
    return hour >= 9 && hour < 18; // 9 AM to 6 PM
  }

  if (isBusinessHours()) {
    window.tf.createWidget('<form-id>', {
      container: document.getElementById('tf'),
      hidden: { url_form: window.location.href }
    });
  }
</script>

 


Reply