Click to See Complete Forum and Search --> : focus question


rab_denver
08-07-2003, 01:06 PM
Hi,
My wife has a form people fill out to submit orders.
Have a check on it to validate the fields and this works ok and if field not completed it returns the focus to the input field that failed as wanted.
When the user has scrolled to the bottom of the page off the field validated it returns to the input field but the title of the field is above out of view.
Is there a way to return to the focus field and display the page the line above that so the title shows?

my current code is
if((field.type=="text" || field.type=="textarea" || field.type=="password") && field.value==""){
alert("Please fill in the '"+field.name+ "' field.")
setTimeout("document.forms[0].elements["+i+"].focus()", 10)
return false
}

thanks
Rab

Zero-x252
08-07-2003, 01:40 PM
try using a <span> tag around the title and using the same code just make the focus the span... but to do this you would have to make it much more complex probably by using o say
focus(field.name + '1')
where the span is
<span name="name1">text</span>
and the field is
<input type="text" name="name">

rab_denver
08-07-2003, 03:33 PM
Thanks for the response,
I've tried your suggestion but may be doing it wrong but always positions the first row as the input field.
I'll try some tomorrow.
thanks again