Reputation: 341
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);
},
Upvotes: 0
Views: 5002
Reputation: 1149
You can set selectionStart and selectionEnd to the value length. e.g.
<input type="text" onFocus="this.selectionStart = this.selectionEnd = this.value.length;" />
Upvotes: 2