Jump to Real's How-to Main page

Make a checkbox read-only

With a small javascript function, you can have a good looking read-only checkbox and not use the greyed disabled look.
<HTML>
<HEAD>
<SCRIPT>
function readOnlyCheckBox() {
   return false;
}
</SCRIPT>
<BODY>
<input type="checkbox" id="cbx1" 
  ` onClick="return readOnlyCheckBox()" CHECKED /> readonly
<br/>
<input type="checkbox" id="cbx2" 
    CHECKED DISABLED/> disabled
</BODY>
</HTML>
It looks like this :

readonly
disabled


If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2007
[ home ]