Javascript: How To Set Cursor to Textbox End

< script language="javascript">
function func()
{
    var t2 = document.getElementById("t2");
    t2.focus();
    t2.value = t2.value;
}
< /script>

The trick is to reset the value of the textbox like that:

t2.value = t2.value;

Don’t put a focus() method after that line, as it won’t work. If you want to focus the control do it before you reset the value.

Advertisement
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s