set readonly attribute to keep the input editable

Is it possible to set "readonly" attribute of an input to keep it editable?

I'm doing a crossword and I can change my function to search for/select a tag using different attribute but I'm still wondering if it is possible.

Thanks for help in advance!

Answers


If the JavaScript readOnly property is set to true (a boolean, not a string), then the control will not be editable.

If the JavaScript readOnly property is set to false (a boolean, not a string), then the control will be editable.

If the HTML readonly attribute is present, then the readOnly property will default to true.

If the HTML readonly attribute is not present, then the readOnly property will default to false.

JavaScript can modify the value property of a control no matter what state the readOnly property has.

There is no way for a control to be edited through the normal browser UI if it is set to readOnly (JavaScript consoles and DOM inspectors are not the normal UI).


The attribute readonly renders the input control noneditable for a user. Using javascript you can still change its value. Setting the readonly attribute in javascript to false has no effect for the user, the input still will be readonly. Removing the attribute will render the input editable for the user again.

You could also use the disabled attribute, with two differences: the field is displayed grayed out, and you can set the disabled attribute directly.

It's all tested/demonstrated in this jsfiddle [note: updated]


I suggest using the html5 supported data- prefix data-readonly="true" https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes


Need Your Help

Asterisk with new functions

sql function odbc asterisk

I created a write func odbc list records files in sql table:

What is wrong with the handlebar code?

javascript node.js backbone.js pug

Hey so I am trying to switch from underscore to handlebar, but nothing is rendering from the model, but the templates are changing correctly. Also, when the editTemplate shows from clicking the edit