How do I set the cursor to a particular position in the string value of a text INPUT field in Internet Explorer?
The following code is working for me in IE 9
<script type="text/javascript">
var input = document.getElementById("myInput");
input.selectionStart = 2;
input.selectionEnd = 5;
</script>
Here is the code that I'm using for IE 6
input.select();
var sel = document.selection.createRange();
sel.collapse();
sel.moveStart('character', this.SelectionStart);
sel.collapse();
sel.moveEnd('character', this.SelectionEnd - this.SelectionStart);
sel.select();