php - How to I disable the textbox by default and enable it later? -


how disable textbox default , let user enable via checkbox?

<input type="checkbox" id="sccb" name="science" value="science"> <script type="text/javascript">     $(document).ready(function(){     $('#sccb').click(function(){     if (this.checked) {     $('#cns').removeattr("disabled");     }     else {     $("#cns").attr("disabled", true);     }     });     }); </script>  <input type="text" id="cns" name="coornamescience" disabled="disabled" size="30"></input> 

use disabled="disabled" textbox , use js/jquery enabled on click

demo - http://jsfiddle.net/jacme/

<textarea rows="4" cols="50" disabled="disabled" id="mytextbox"> </textarea>  <input type="checkbox" id="checkbox1" /> 

and use javascript/jquery -

$(document).ready(function(){     $('#checkbox1').click(function(){     if (this.checked) {     $('#mytextbox').removeattr("disabled");     }     else {     $("#mytextbox").attr("disabled", true);     }     }); }); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -