This article describes the method of JS controlling read-only or writable properties of text fields. Share it for your reference, as follows:
<input id="username" name="userneme" type="text" size=106>Password:<input id="userpwd" type="text" name="userpwd" size=106><input name="content" type="checkbox")" value="checkbox" onclick="changeCheck()"/>Posted anonymously (without registration)<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>Notice:
Read-only and unavailable above are generally not available, so you don’t need to read-only. You can choose appropriately
There is no ONCHANGE event in the CHECKBOX control in HTML, only RADIO, CHECKBOX only has ONCLICK event in CHECKBOX
For more information about JavaScript related content, please check out the topics of this site: "Summary of JSON operation techniques in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques" and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.