function focusInitialField() {
var fields = document.getElementsByTag Name('input');
var firstfield = fields.getAttribute( "text")[0];
if ((firstfield) %26amp;%26amp; (firstfield.value === '')) { firstfield.focus(); }
}
Then you'd call to the function onload.
Why does this cause IE to throw a JS error?safari browser
function focusInitialField()
{
var fields = document.getElementsByTagName('input');
for ( var x = 0; x %26lt; fields.length; x++ )
{
if (fields[x].getAttribute('type') == "text" %26amp;%26amp; fields[x].value == "")
{
fields[x].focus();
break;
}
}
}
[edit]
i like this idea. it will loop through all the input elements and set focus on the first text box.
No comments:
Post a Comment