Tuesday, March 4, 2008

How to set focus at the end of the Text in a Textbox using Javascript

//Setting Focus At the end of the Text in a TextBox
function SetEnd (obj)
{
var ctrl=document.getElementById(obj.id);
if (ctrl.createTextRange)
{
var FieldRange = ctrl.createTextRange();
FieldRange.moveStart('character', ctrl.value.length);
FieldRange.collapse();
FieldRange.select();
}
}

No comments:

 
Feedback Form