Mobile Web: Set cursor position to the end of a text field.

If you want to place the cursor at the end of the text box, simply add the following code :
 
elm.addEventListener("focus", function() {this.value=this.value}, false);
 
 
But if your code is designed for mobile browsers, it will not work.
Use this code:
 
elm.addEventListener("focus", function(){
             if(this.setSelectionRange) {
           var _this = this;
           setTimeout(function(){
                                    _this.setSelectionRange(9999, 9999);
                                }, 0);
             } else
                 this.focus();
   }, false);
 
 
Why do you want to do this?
If your site has the direction="RTL", then after the text field gets focus, the cursor is placed not at the end of the field and in the beginning.
So you can't add text to the end and erase text by backspace.