Javascript Reference
Categories: InputTypePassword

javascript InputTypePassword selectionEnd, selectionStart

@March 15, 2008, 1:22 a.m.
selectionEnd, selectionStartFirefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM n/a  


The selectionEnd and selectionStart properties are convenience properties introduced with Netscape 6. They allow scripts to get and set the end positions of a text selection within a text-oriented input element. Values are zero-based integer counters of positions between characters in the text entered into the field. When both properties have the same value, the visual result is the same as a text insertion pointer. For example, to place the cursor at the end of a text box, set the two values to the element's text length (see the textLength property). The equivalent IE functionality requires creating an IE text range in the element, adjusting the range's endpoints, and selecting the range (see the TextRange object).

var elem = document.forms[0].myPassword;
elem.selectionEnd = elem.textLength;
elem.selectionStart = elem.textLength;

Positive integer.



Powered by Linode.