form.js 555 Bytes
Newer Older
1
/* eslint-disable no-unused-vars */
2

3 4 5 6 7 8
function setInputSelection (input, startPos, endPos) {
  input.focus()
  if (typeof input.selectionStart !== 'undefined') {
    input.selectionStart = startPos
    input.selectionEnd = endPos
  } else if (document.selection && document.selection.createRange) {
9
        // IE branch
10 11 12 13 14 15 16 17
    input.select()
    var range = document.selection.createRange()
    range.collapse(true)
    range.moveEnd('character', endPos)
    range.moveStart('character', startPos)
    range.select()
  }
}
18 19

/* eslint-enable no-unused-vars */