Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable a textbox using CSS

Tags:

css

textbox

How to disable a textbox in CSS? Currently we are having a textbox in our view which can be enabled/disabled depending on a property in the model. We are having asp.net MVC view; depending on the value of the Model property we need to either render a textbox or readonly textbox. we were thinking of doing this by applying CSS to the view control. Has someone done this earlier?

like image 424
Balaji Avatar asked Mar 16 '10 22:03

Balaji


People also ask

How do I disable a text box in CSS?

You can't disable a textbox in CSS. Disabling it is not a presentational task, you will have to do this in the HTML markup using the disabled attribute.

How do I disable a textbox?

We can easily disable input box(textbox,textarea) using disable attribute to “disabled”. $('elementname'). attr('disabled','disabled'); To enable disabled element we need to remove “disabled” attribute from this element.

How do I disable something in CSS?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.

How do I make input field Disabled in CSS?

You can disable form fields by using some CSS. To disable form fields, use the CSS pointer-events property set to “none”.


1 Answers

you can disable via css:

pointer-events: none;  

Doesn't work everywhere though.

like image 73
abbie Avatar answered Oct 15 '22 13:10

abbie