Home > Web Front-end > JS Tutorial > body text

Methods and techniques for controlling the read-only or writable attributes of a text field using JS

怪我咯
Release: 2018-05-21 11:00:21
Original
1857 people have browsed it


The examples in this article describe the JS method of controlling the read-only or writable attributes of a text field. Share it with everyone for your reference, the details are as follows:

<input id="username" name="userneme" type="text" style="width:50px" size=106>
密码:<input id="userpwd" type="text" name="userpwd" size=106 style="width:50px">
<input name="content" type="checkbox")" value="checkbox" onclick="changeCheck()"/>
匿名发表(免注册)
<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>
Copy after login

Note: is read-only and unavailable above. If it is generally unavailable, there is no need to read-only. It is ok. Select appropriately
There is no
ONCHANGE event in the HTML CHECKBOX control, only RADIO has it, and CHECKBOX only has the ONCLICK event

The above is the detailed content of Methods and techniques for controlling the read-only or writable attributes of a text field using JS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!