M
Matt
I encountered the problem to disable or enable READONLY attribute.
This is my html file. When the user check the checkbox, it will enable
the field, and when the user uncheck the checkbox, it will make the
field read only.
If I use disable attribute, it is working fine. But I want to use
READONLY attribute. Field name h1 with disabled attribute is working
fine, but field name h2 is not working. Any ideas?? Thanks!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Exact Match Form</TITLE>
<script type="text/javascript">
//only affect standard fields
function disableControls(bValue)
{
InputForm.h1.disabled = bValue;
InputForm.h2.readonly = bValue;
}
function cbIgnoreValidation_onclick()
{
if (InputForm.cbIgnoreValidation.checked == true)
{ disableControls(false);
}
else
{ disableControls(true);
}
}
</script>
</head>
<body>
<form name="InputForm">
<P>Field With DISABLED ATTRIBUTE: <INPUT TYPE="TEXT" name="h1" size=25
maxlength=6 value="disabled field" DISABLED>
<P>Field With READONLY ATTRIBUTE: <INPUT TYPE="TEXT" name="h2" size=25
maxlength=6 value="readonly field" READONLY>
<INPUT type="checkbox" name="cbIgnoreValidation"
onClick="cbIgnoreValidation_onclick()"> Ignore
Validation
</form>
</body>
</html>
This is my html file. When the user check the checkbox, it will enable
the field, and when the user uncheck the checkbox, it will make the
field read only.
If I use disable attribute, it is working fine. But I want to use
READONLY attribute. Field name h1 with disabled attribute is working
fine, but field name h2 is not working. Any ideas?? Thanks!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Exact Match Form</TITLE>
<script type="text/javascript">
//only affect standard fields
function disableControls(bValue)
{
InputForm.h1.disabled = bValue;
InputForm.h2.readonly = bValue;
}
function cbIgnoreValidation_onclick()
{
if (InputForm.cbIgnoreValidation.checked == true)
{ disableControls(false);
}
else
{ disableControls(true);
}
}
</script>
</head>
<body>
<form name="InputForm">
<P>Field With DISABLED ATTRIBUTE: <INPUT TYPE="TEXT" name="h1" size=25
maxlength=6 value="disabled field" DISABLED>
<P>Field With READONLY ATTRIBUTE: <INPUT TYPE="TEXT" name="h2" size=25
maxlength=6 value="readonly field" READONLY>
<INPUT type="checkbox" name="cbIgnoreValidation"
onClick="cbIgnoreValidation_onclick()"> Ignore
Validation
</form>
</body>
</html>