tags:

views:

567

answers:

4

I want the font color to change in a textarea as I type in specific keywords, like in Visual Studio.

I have not seen this anywhere, so I don't know if this is possible with HTML and JavaScript.

Has anyone seen anything like this? Or know how to write it?

+2  A: 

Check out EditArea, it has an impressive looking example up.

Paolo Bergantino
+1  A: 

Have a look at CodePress, which has some nice looking examples on its home page.

Simon Lieschke
A: 

You would probably have to run javascript on the client to detect when the text changes, then replace the text to be highlighted with some child html elements with the proper style.

For example

Original text:

This is what the user typed.

Highlighted text

This is what the <a class="className">user</a> typed.
TJB
+1  A: 

Textarea is a standard HTML element and so was invented just after the dawn of time. Unfortunately this means it is limited in it's appearance and functionality.

Changing the colours of specific words is not possible as far as I know. However a way to get around this would be to have an iFrame embedded in the page. That way, you can treat the iFrame content as another web page and style it using CSS.

The Yahoo RTE, the FCKEditor and the Lightweight RTE works in this way.

Another option, which does not use an iFrame is the editor used here on Stack Overflow, known as the WMD. The files are here.

Jon Winstanley