How can I highlight a word in a text component from JavaScript? [For instance, as the result of a spell check.]
Created May 4, 2012
Jayesh Nazre Well you can highlight that using the select() function:
If you need to highlight only specific text in a text box then that's not possible. For example, if the text box contains "hi there", then you cannot highlight "there" only. The entire text "hi there" will get highlighted.
<html> <head> <Script language=javascript> function test() { document.frm_test.txt_value.select(); } </script> </head> <body> <form name=frm_test id=frm_test> <input type=test value=Hi name=txt_value id=txt_value> <input type=button onclick="test()" value=Highlight> </form> </body> </html>Note:
If you need to highlight only specific text in a text box then that's not possible. For example, if the text box contains "hi there", then you cannot highlight "there" only. The entire text "hi there" will get highlighted.