Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there selected text in my input type=text??? 1

Status
Not open for further replies.

BKQc

Programmer
Jul 26, 2002
118
CA
Anyone knows a way to find if there is text selected inside a input type=Text component? If it's possible, can I retrieve the text inside this selection? I tried with the getTextRange() method but it always return the whole VALUE content.
 
BKQc

here's some javascript that will work:

you can use the onselect event of the textbox
IE
document.selection.createRange().text

don't know about vbscript
good luck
tsmith
 
or better yet you can call it on the onmouseup event

<input type=&quot;text&quot; onmouseup=&quot;alert(document.selection.createRange().text)&quot;>

tsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top