Click to See Complete Forum and Search --> : Focus method not working


florida
05-21-2004, 01:37 PM
I am trying to get the form to focus on the checkbox field if it is left blank.

I keep getting errors on the focus method saying "Object doesnt support this property or method".


for(x=0;x<document.myform.myfieldname.length;x++)
{
if(document.myform[x].checked)
var checked;
}

if(!checked)
{
alert('Checkbox is not checked');
document.myform.myfieldname.focus();
return false;

}

Pittimann
05-21-2004, 01:46 PM
Hi!

That is definately not a way to validate your stuff; can you please post your html as well in order to make it easier for us to provide a satisfactory solution?

Cheers - Pit

Kor
05-22-2004, 03:04 AM
document.myform[x].checked has no sense as it will reffere the forms (if more than one) not the checkbox. The limit document.myform.myfieldname is also questionable...

As Pittiman said, show us the whole HTML...

florida
05-22-2004, 07:42 AM
Thanks I will not use the focus() method and I will use radios instead. It works fine now and thanks for telling me what I needed to know.