File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Highlighting a portion of text in a textarea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Highlighting a portion of text in a textarea" Watch "Highlighting a portion of text in a textarea" New topic
Author

Highlighting a portion of text in a textarea

Kamal Pathi
Greenhorn

Joined: Dec 20, 2002
Posts: 1
How to select/highlight a portion of text in a textarea programmatically using javascript?
For example.
There is a text box which is having values
let us as 1234 ABCD. Onload I want to select/highlight the characters AB.
Michael McNally
Ranch Hand

Joined: Aug 22, 2002
Posts: 53
You need to make a RegExp (regular expression) for this. THe RegExp below searches text in an object. When it finds any a character followed by any b character...it finds a match for a function you can then create such as select() for a text object.
I am not sure about this but here is my guess:
text.select('/([aA][bB])/')
i am sure about the RegExp but not sure if i wrote it correctly. im not even sure if i implemented it correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Highlighting a portion of text in a textarea
 
Similar Threads
JSF TextArea to highlight the content
Highlight search terms in inputtextarea
Display tooltip when mouse is hovered on a certain word in textarea
JTextArea color
Highlighting Text in JEditorPane/JTextArea