(1) Click the checkbox to make the input box available, otherwise gray cannot be used
<li> <span class= "Sample_li_left" > <asp:checkbox id= "GQSJ" runat= "Server" Checked onclick= " Dodisabled (this.checked); " /> Expiry time:</span> <span> <input id= "Expiretime" name= "Expiretime" type= "text" class= "time_ Text "onfocus=" Wdatepicker ({datefmt: ' Yyyy-mm-dd ', maxdate: '%y-%m-%d '}) "runat=" Server "/> </span> </li>
The corresponding JS function is:
function dodisabled (checked) {if (checked) {$ ("#expireTime"). Get (0). Disabled = ""; $ ("#expireTime"). AddClass (' Time_text '); $ ("#expireTime"). CSS (' background ', ' url (.. /images/time.gif) #ffffdc no-repeat right Top ');} else{$ ("#expireTime"). attr (' disabled ', ' disabled '); $ ("#expireTime"). CSS (' background ', ' #CCCCCC ');}}
Legacy issues are:
$ ("#expireTime"). AddClass (' Time_text '); With $ ("#expireTime"). CSS (' background ', ' url (.. /images/time.gif) #ffffdc no-repeat right top ');
Should be the same, but the latter can not be the former.
Reference: http://blog.csdn.net/delongcpp/article/details/8171826
Set the HTML text box to a non-editable text box.
Method 1:onfocus=this.blur ()
<input type= "text" name= "INPUT1" value= "Non-editable text box" Onfocus=this.blur () >
Method 2:readonly
<input type= "text" name= "INPUT1" value= "Non-editable text box" readonly>
<input type= "text" name= "INPUT1" value= "Non-editable text box" readonly= "true" >
Method 3:disabled
<input type= "text" name= "INPUT1" value= "Non-editable text box" disabled>
To make the text box grayed out, do not enter:
<input type= "text" name= "test" disabled= "disabled" style= "background: #CCCCCC"/>
Non-input can also be used in the above three ways
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use a checkbox to control whether the text box is dimmed or not editable