Dave_Williams Dave_Williams - 1 year ago 86
Javascript Question

How to change character in textarea value?

So, say I have a textarea.

<textarea id="area">Test text</textarea>

How can I search for a specific string (For example, "text") and remove it?

I tried this, but to no avail.

document.getElementById("area").replace('text', '');

Any and all help is appreciated!

Answer Source

Simple and easy JavaScript fix:

var area = document.getElementById("area");
area.value = area.value.replace('search', 'string');

This should work with your original TextArea:

<textarea id="area">Test text</textarea>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download