Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Highlighting a portion of text in a textarea

 
Kamal Pathi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic