function isreadonly(){ var obj = document.getElementById("username"); obj.setAttribute("readOnly",true); obj.style.backgroundColor="#d2d2d2"; } function readwrite(){ var obj = document.getElementById("username"); obj.setAttribute("readOnly",false); obj.style.backgroundColor="#ffffff"; } script>