I want to know if I can use a content editable div
instead of a textarea
? Will the functionality same? Can I process the data as same as textarea
data?
Asked
Active
Viewed 8,100 times
2
-
1Is this a theoretical question, or do you have a practical motivation for switching from textarea to div? – Gogowitsch Feb 09 '13 at 13:21
2 Answers
5
You can use an contenteditable div similar to a textarea, see JSFiddle
<form action="form.php" method="post">
<div name="text" contenteditable="true">This text can be edited by the user.</div>
<input type="submit" value="Send" name="send" />
</form>
But as you can see, it is not automatically sent with the form as an input element or a textarea. If you want such functionality, you must use some javascript.

Olaf Dietsche
- 72,253
- 8
- 102
- 198
1
Yes you can use it if you like. Also this will give you advantage of displaying images and other html elements where as textareas are only limited to texts. So many WYSIWYG editors like FCK or CK editors use content editable divs where you provide input instead of a textarea.
Regarding processing data, you'll have to take help of javascript. It'll not act like a textarea where you can directly post the data when you use it along with a form.

Ghost-Man
- 2,179
- 1
- 21
- 25