Javascript controls the read-only or writable attributes of text fields. JS text

Source: Internet
Author: User

Javascript controls the read-only or writable attributes of text fields. JS text

This article describes how JavaScript controls the read-only or writable attributes of text fields. We will share this with you for your reference. The details are as follows:

<Input id = "username" name = "userneme" type = "text" style = "width: 50px" size = 106> password: <input id = "userpwd" type = "text" name = "userpwd" size = 106 style = "width: 50px "> <input name =" content "type =" checkbox ")" value = "checkbox" onclick = "changeCheck ()"/> anonymous posting (registration-free) <script language = "JavaScript"> <! -- Function changeCheck () {var aa = document. getElementById ("username"); var bb = document. getElementById ("userpwd"); var cc = document. getElementById ("content"); if (cc. checked) {aa. readonly = true; bb. readonly = true; aa. disabled = true; bb. disabled = true;} else {aa. readonly = false; bb. readonly = false; aa. disabled = false; bb. disabled = false ;}/// --> </SCRIPT>

Note:

In the above, read-only and unavailable are generally not available, so you do not need to read-only, you can select appropriate
In the CHECKBOX control of HTML, there is no ONCHANGE event, only RADIO exists, and CHECKBOX only has an ONCLICK event.

Related Article

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.