form.js 555 B

12345678910111213141516171819
  1. /* eslint-disable no-unused-vars */
  2. function setInputSelection (input, startPos, endPos) {
  3. input.focus()
  4. if (typeof input.selectionStart !== 'undefined') {
  5. input.selectionStart = startPos
  6. input.selectionEnd = endPos
  7. } else if (document.selection && document.selection.createRange) {
  8. // IE branch
  9. input.select()
  10. var range = document.selection.createRange()
  11. range.collapse(true)
  12. range.moveEnd('character', endPos)
  13. range.moveStart('character', startPos)
  14. range.select()
  15. }
  16. }
  17. /* eslint-enable no-unused-vars */