readonly input code example
Example 1: readonly attribute in html by javascript
document.getElementById("yourID").readOnly = true;
Example 2: read only attribute in html
<!-- Using readonly attribute is use to prevent changing of input value. -->
Example:
<input type="text" name="username" value="ankur" readonly>
Example 3: checkbox readonly
<input type="checkbox" onclick="return false;"/>