Forums

Forums / General Discussions / Best way to expire a form when user takes too long to submit

Best way to expire a form when user takes too long to submit

3 posts, 1 answered
  1. Mike Cohen
    Mike Cohen avatar
    31 posts
    Registered:
    10 Aug 2021
    12 Dec 2023
    Link to this post
    Hello, we have a web form that does not require authentication.  The form first requires picking an eligible date from a specified list from our CRM and then populating a number of web form fields and finally submitting. 

    What is the best way to expire/invalidate the form if the user does not populate and submit the form within a reasonable amount of time (eg. 10 minutes). 

  2. Eric Mann
    Eric Mann avatar
    59 posts
    Registered:
    16 Oct 2020
    14 Dec 2023 in reply to Mike Cohen
    Link to this post
    Mike,
    We use this type of JavaScript for timeout then we add in whatever action based on that tmeout such as redirect, alert message, or disable fields. 

    $(document).on("tpc:ready", function (event, tpcObject) {
      const myTimeout = setTimeout(function () {
        // Loop through widgets in first form on page and disable
        for (widget in tpc.forms[0].$$instance.get_formWidgets()) {
          try {
            tpc.forms[0].$$instance.get_formWidgets()[widget].disable();
          } catch {}
        }

        // Disable buttons
        $(".tpc-formflow-buttons").children(".btn").prop("disabled", true);

        // Clear the timeout (to prevent re-running)
        clearTimeout(myTimeout);
      }, 5000);
    });
    - Eric 
  3. Mike Cohen
    Mike Cohen avatar
    31 posts
    Registered:
    10 Aug 2021
    Answered
    14 Dec 2023 in reply to Eric Mann
    Link to this post
    Thank you Eric, this is just what I was looking for. 


3 posts, 1 answered