Edit This Code:
<!DOCTYPE html>
<html>
<body>

Name: <input type="text" id="myText">

<p>Click the button to set the text field to read-only.</p>

<p><strong>Tip:</strong> To see the effect, try to type something in the text field before and after clicking the button.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("myText").readOnly = true;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy