Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the value of a readonly textbox using jQuery?

Tags:

jquery

How can I change the value of a HTML textbox which has readonly property using jQuery?

like image 424
user838697 Avatar asked Jul 12 '11 17:07

user838697


People also ask

How make readonly TextBox editable using jQuery?

$('input[type="text"], textarea'). attr('readonly','readonly'); 0.

How do I remove the Read Only property of a TextBox using jQuery?

$("#<%fieldname. ClientID%>"). attr("readonly","false");

How do I remove a readonly attribute?

In the event handler function of the remove button, we are calling the removeAttribute() method of the input element to remove readonly attribute.

How do you make a selection readonly in jQuery?

$('#cf_1268591'). attr("readonly", "readonly");


2 Answers

Wait, did you want to remove the read only? If so:

$('textbox').removeAttr('readonly').val('Changed Value'); 

if not:

$('textbox').val('Changed Value'); 
like image 166
Phil Avatar answered Oct 01 '22 17:10

Phil


$('my-textbox').val('new value') 

The read only property only applies to the user viewing the page, not the JavaScript that accesses. it

like image 38
Greg Guida Avatar answered Oct 01 '22 18:10

Greg Guida