:: Forum >>

set caret position for Input control


I am rephrasing my previous question to a more useful generic one:

how would one set the caret position on an Input control?
Eric Juvet
Thursday, February 7, 2008
In IE you should create a text range, move it to the desired position and then call select() method of the text range. In other browsers you can manipulate the selection using selectionStart/End properties of the input element.

Here is the sample code which moves the selection to the end of the text -

obj.onControlEditStarted = function(){
        var e = this.element().getElementsByTagName("INPUT")[0];
        if (AW.ie) {
            var r = e.createTextRange();
        else {
            e.selectionStart = e.selectionEnd;
Alex (ActiveWidgets)
Thursday, February 7, 2008
Thank you very much, Alex, truly appreciate your help.

Every place that I work at as a contractor, I require them to purchase ActiveWidgets.
Eric Juvet
Thursday, February 7, 2008

This topic is archived.

Back to support forum

Forum search