html - How do I disable form fields using CSS? -


is possible disable form fields using css? of course know attribute disabled, possible specify in css rule? -

<input type="text" name="username" value="admin" > <style type="text/css">   input[name=username] {     disabled: true; /* not work */   } </style> 

the reason i'm asking that, have application form fields autogenerated, , fields hidden/shown based on rules (which run in javascript). want extend support disabling/enabling fields, way rules written directly manipulate style properties of form fields. have extend rule engine change attributes style of form fields , somehow seems less ideal.

it's curious have visible , display properties in css not enable/disable. there in still-under-works html5 standard, or non-standard (browser specific)?

since rules running in javascript, why not disable them using javascript (or in examples case, jquery)?

$('#fieldid').attr('disabled', 'disabled'); //disable $('#fieldid').removeattr('disabled'); //enable 

update

the attr function no longer primary approach this, pointed out in comments below. done prop function.

$( "input" ).prop( "disabled", true ); //disable $( "input" ).prop( "disabled", false ); //enable 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -