homerUK
10-29-2003, 02:49 PM
hey,
I've got a simple form with some validation... when a user enters an incorrect value, it alerts them and clears the field... I then wanted it to focus back on that field.
my Js is:
function check(what)
{
value = what.value;
if (value > 100)
{
alert("cannot be greater than 100");
what.value = "";
what.focus();
return false;
}
}
then I have a text field like the following:
<input name="a" type="text" id="a" onChange="check(this)">
so when the value is changed it will check it, and if greater than 100, alert an error, clear the field (which both work) but the focus moves to the next field.
what am I doing wrong?!
thanks!
Matt
I've got a simple form with some validation... when a user enters an incorrect value, it alerts them and clears the field... I then wanted it to focus back on that field.
my Js is:
function check(what)
{
value = what.value;
if (value > 100)
{
alert("cannot be greater than 100");
what.value = "";
what.focus();
return false;
}
}
then I have a text field like the following:
<input name="a" type="text" id="a" onChange="check(this)">
so when the value is changed it will check it, and if greater than 100, alert an error, clear the field (which both work) but the focus moves to the next field.
what am I doing wrong?!
thanks!
Matt