S
Seansan
Hi, am having some troubles with timeouts. The code starts at
verifyform. I was debugging and tested hitting the form submit twice
(within 3 seconds)!
In IE6 I get an error saying that I have an error when I set timerID =
0; In Firefox the form submits the second click which it shouldnt do as
all values are still empty (within the 3 seconds).
Any ideas?
kind regards, seansan
<CODE STARTS HERE>
var timerID = 0;
var msgtime = 3000;
// Define empty function
function empty(varname)
{
return(varname == '');
}
// Verify form contents
function verifyform(frm)
{
var _user = frm._user.value;
var _pass = frm._pass.value;
if (empty(_user) || empty(_pass))
{
set_message('message', 'Please enter your username and a password');
return false;
} else {
return true;
}
}
function clear_message(lbl)
{
document.getElementById(lbl).innerHTML = ' ';
}
// Set error message text
function set_message(lbl, txt)
{
if (timerID) {
clearTimout(timerID);
timerID = 0;
}
document.getElementById(lbl).innerHTML = txt;
var clear_message = "clear_message('" + lbl + "');";
timerID = window.setTimeout(clear_message, msgtime);
}
verifyform. I was debugging and tested hitting the form submit twice
(within 3 seconds)!
In IE6 I get an error saying that I have an error when I set timerID =
0; In Firefox the form submits the second click which it shouldnt do as
all values are still empty (within the 3 seconds).
Any ideas?
kind regards, seansan
<CODE STARTS HERE>
var timerID = 0;
var msgtime = 3000;
// Define empty function
function empty(varname)
{
return(varname == '');
}
// Verify form contents
function verifyform(frm)
{
var _user = frm._user.value;
var _pass = frm._pass.value;
if (empty(_user) || empty(_pass))
{
set_message('message', 'Please enter your username and a password');
return false;
} else {
return true;
}
}
function clear_message(lbl)
{
document.getElementById(lbl).innerHTML = ' ';
}
// Set error message text
function set_message(lbl, txt)
{
if (timerID) {
clearTimout(timerID);
timerID = 0;
}
document.getElementById(lbl).innerHTML = txt;
var clear_message = "clear_message('" + lbl + "');";
timerID = window.setTimeout(clear_message, msgtime);
}