This blog is moved to
http://amalhashim.wordpress.com

Wednesday, July 9, 2008

Placing cursor at the end of the text in a textbox

function SetCursorToTextEnd(textControlID)
{
var text = document.getElementById(textControlID);
if (text != null && text.value.length > 0)
{
if (text.createTextRange)
{
var FieldRange = text.createTextRange();
FieldRange.moveStart('character', text.value.length);
FieldRange.collapse();
FieldRange.select();
}
}
}

No comments: