0

I'm using jQuery masked input plugin, and when I take the focus of the field and return the focus (blur, focus) the cursor back to the beginning, need to always leave the cursor at the end but I can not.

$('#id_origin_zipcode').bind('focus', $.proxy(this.moveCursorToEnd, this));

moveCursorToEnd: function(e){
    var value = $('#id_origin_zipcode').val();
    $('#id_origin_zipcode').val(value);

},
Vanderson Ramos
  • 341
  • 1
  • 4
  • 15

1 Answers1

2

You can set selectionStart and selectionEnd to the value length. e.g.

<input type="text" onFocus="this.selectionStart = this.selectionEnd = this.value.length;" />
NoGray
  • 1,149
  • 7
  • 9