June 24, 2008

need to set the cursor at the end of text in textbox

function setSelectionRange(input, selectionStart, selectionEnd) {
if (input.setSelectionRange) {
input.focus();
input.setSelectionRange(selectionStart, selectionEnd);
}
else if (input.createTextRange) {
var range = input.createTextRange();
range.collapse(true);
range.moveEnd('character', selectionEnd);
range.moveStart('character', selectionStart);
range.select();
}
}
function setCaretToEnd (input) {
setSelectionRange(input, input.value.length, input.value.length);
}

Subscribe to

Add to Google
Add to My Yahoo!
Subscribe Via Web Feed
kick it on DotNetKicks.com