Thursday, May 2, 2013

Function to bring focus to a html field element


function focusField(field) {
var myField;
if (typeof field==='string')
myField=document.getElementById(field);
else if (typeof field=='undefined')
return;
else myField=field;

window.setTimeout(function ()
    {
myField.focus();
myField.select();
}, 0);
}

No comments:

Post a Comment