• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Highlighting a portion of text in a textarea

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic