I'm writing a javascript class for form validation and have a problem moving focus to form elements through the object.

The focus will move to the form element for a split second before going.

This won't work when called within the class:
document.forms[0].elements[2].focus();

Does anyone know the answer or the reason it does this?

Many thanks in Advance.