This article illustrates the method of JS controlling the read-only or writable property of text field. Share to everyone for your reference, specific 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 (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>
Attention:
Read-only and not available on the above generally can not use the Read only, you can choose the appropriate
There is no onchange event in the CheckBox control of HTML, only radio, checkbox only onclick event
More readers interested in JavaScript-related content can view this site: "JavaScript in the JSON Operation tips Summary", "JavaScript switching effects and techniques summary", "JavaScript Search Algorithm Skills summary", " JavaScript animation effects and tips Summary, "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary" and "JavaScript Mathematical operation Usage Summary"
I hope this article will help you with JavaScript programming.