Enforcing a time limit on a page using JavaScript, C# (ASP.NET 1.1) and display a countdown timer also.
February 10, 2010 1:48 AM

I need to enforce a five minute time limit on a page using JavaScript, C# (ASP.NET 1.1) and display a countdown timer also.

I have a webpage containing a form and a number of webcontrols. If the form has not been submitted by by the user within 5 minutes, I need the form to submit automatically. I also need to display a countdown timer which will show how much time is left. I know that any solution is likely to have its flaws and will probably be easy to hack, that is not too much of a concern right now as time is tight and the consequences of people cheating the timer are small. In any case I will be tracking the start and finish times in the code behind. Thanks.
posted by therubettes to Computers & Internet (2 answers total) 1 user marked this as a favorite
The basics of the form submission are:

setTimeout('submitForm()', 5*60*1000);

where submitForm is a function that looks like:

function submitForm() {
   document.getElementById('form_id').submit();
}

This will submit a form with the id 'form_id' after 5 minutes.

And here's an example of a countdown timer (because I'm too lazy to write one for you).
posted by le morte de bea arthur at 1:59 AM on February 10, 2010


Looks good le morte.
Thanks a bunch.
posted by therubettes at 2:13 AM on February 10, 2010


« Older Fawlty Memory: Help me find a TV show.   |   US Work Visa - What type should I be applying for? Newer »
This thread is closed to new comments.