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.