readonly attribute in html by javascript

JavaScript
document.getElementById("yourID").readOnly = true; 
Source

Also in JavaScript: