View Full Version : Replace text in textarea

07-07-2004, 08:26 PM
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

function replace(){
document.form.txt.replace(/&lt;script&gt;/, "<font color='red'>&lt;script&gt;</font>");
<form name="form">
<textarea name="txt" cols="20" rows="20" onKeyUp="javascript:replace();">test &lt;script&gt;</textarea>


You problably understand what I want to get out of this. :confused:

I want that when you eg. write "<script>" in the textarea it turns red (only the word script)

I'm not totally of the road with this code right? Please help... :o

Willy Duitt
07-07-2004, 08:55 PM
You can not do that. The textarea text color is all the same color.

07-08-2004, 09:28 AM
but it should be possible if i use editable div's right?


<style type="text/css">
DIV.editor {
width: 60%;
height: 100%;
font-family: Courier New;
font-size: 13px;
padding: 10px;
border: 1px solid #000000;

<div id="editor" class="editor" contentEditable></div>

but I can't put it together, please help...

07-08-2004, 11:30 AM
but it should be possible if i use editable div's right?

yes, but you can't directly submit them to the server. you'll have to copy their contents, plus any extra formatting markup to a hidden textarea, before submission.

07-10-2004, 07:03 PM

I only want it to be an editor with. No submissions or whatever you're talking about. Can someone givé a code example???

Sorry but this is really beginning to get on my nerves