Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make textarea with readonly=false editable?

I have a form and a textarea field in it. I need to make it editable, and I don't know how.

<textarea id="note" class="input" type="text" name="note">Suggest changes</textarea>

When I inspect elements, its readonly attribute is already false, but it won't let me change anything.

I've tried:

document.getElementsByTagName("textarea")[0].readonly = false;
$("#note").prop('readonly', false);
$("#note").removeAttr('readonly');

None of those help.

like image 585
DR_ Avatar asked Dec 05 '14 09:12

DR_


People also ask

Can you make a textarea not editable?

The readonly attribute is a boolean attribute. When present, it specifies that a text area should be read-only. In a read-only text area, the content cannot be changed, but a user can tab to it, highlight it and copy content from it.

Is textarea editable?

By default, a textarea is editable. So you must have made something that make it uneditable.

Is readonly a valid attribute for textarea?

The <textarea> element also accepts several attributes common to form <input> s, such as autocomplete , autofocus , disabled , placeholder , readonly , and required .

How do I make a textarea readonly in HTML?

The <textarea> readonly attribute in HTML is used to specify that the textarea element is read-only.


Video Answer


2 Answers

The problem is here

document.getElementsByTagName("textarea")[0].readonly = false;

It should be

document.getElementsByTagName("textarea")[0].readOnly = "false";

Or also in your case

document.getElementById("note").readOnly = "false";
like image 192
cesar_sr91 Avatar answered Oct 29 '22 22:10

cesar_sr91


Try

$("#note").attr("readonly", false); 
like image 44
Bhumi Shah Avatar answered Oct 29 '22 22:10

Bhumi Shah