Click to See Complete Forum and Search --> : focus() only stays focussed for a split second


digiti0
05-29-2003, 08:49 AM
Hi,
I have the following onSubmit code to check for blank fields. It displays the alert and then focuses for a split second on the blank field. Then the cursor disappears and it seems that the fields below the blank field are re-displayed, like the page is reloading. Any ideas on why the cursor is not staying in the blank field once it gets there?

Thanks!


function CheckInput(form)
{
if (isempty(trim(form.last_nme.value)))
{
alert("Last name is a required field.");
form.last_nme.focus();
return false;
}
}

xyz
05-29-2003, 09:10 AM
Clearly looks like something else is affecting it.
Debug to see which code is executed after this function.

Gollum
05-29-2003, 09:14 AM
Possibly something like another HTMLElement with an onblur event handler

digiti0
05-29-2003, 12:19 PM
thank you, sorry to waste your time, it was because i was executing the function from an onClick event on the submit button, not an onSubmit event on the form