Add a Time Limit to Submission Forms

Add a Time Limit to Submission Forms

Version 6

A ticking clock can be an excellent motivator. In certain situations such as surveys, questionnaires and polls, a time limit can help ensure that the users enter their first opinion and don’t over-analyze. This article explains how you can add a time limit to your Submission Form DataPages that includes visual feedback and will automatically submit the form when time runs out. This implementation includes a pie timer using the HTML5 canvas tag (View the original source code of the HTML5 pie clock ). For non-HTML5 ready browsers, there is a countdown of remaining seconds.

Steps to implementing a countdown clock:

1. Create a Submission Form DataPage

Create your submission form normally. Remember that since this form will be submitted whether or not the user has finished keep the following things in mind:

All required information should be separated to another Submission Form. Errors caused by required fields will reload the DataPage and reset the timer.

Consistency in question type will allow users to complete more questions. For example, multiple choice (radio buttons), true/false (checkboxes), short answer (text fields), and essay questions (text areas) are all easily created in a Submission Form. Try to group questions by type so that time is not lost due to frequent changes in instructions.

2. Insert the following JavaScript code

This code includes both the HTML5 solution and the fallback code for non-HTML5 ready browsers. Using the insert button at the bottom-right of the DataPage Elements panel, insert an HTML block. Go to the Source mode and insert the following code.

3. Adjust the code as needed

Adjust the time: Find the line that starts var myseconds = 30; This is the number of seconds for your timer.

Adjust the pie timer color: The mycolor variable is located immediately after the myseconds variable. You can adjust the color and transparency using rgba format. You can use an online color picking tool to find the appropriate values for red (255), green (100), and blue(0). The last value (0.8) determines the opacity of the pie timer.

Adjust the pie timer size: The pie timer size can be adjusted using the height and width variables near the top of the code.

Adjust the counter: The text used for non-HTML5 ready browsers can be adjusted by changing the CSS style attributes located near the top of the code. Color, font-family, and font-size can all be adjusted to suit your needs.

Adjust the user warning message: The users will see a message saying how many minutes and how many seconds are available for them to complete the following form.

Please note: This article uses external HTML, JavaScript, or third-party solutions to add functionality outside of Caspio Bridge’s standard feature set. These solutions are provided “as is” without warranty, support or guarantee. The code within this article is provided as a sample to assist you in the customization of your web applications. You may need a basic understanding of HTML and JavaScript to implement successfully.