Use a checkbox to control whether the text box is dimmed or not editable

Source: Internet
Author: User


(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.