How to make Input Readonly in JavaScript

Change element’s readOnly to true.

element.readOnly = true;

Example:

<input type="text" id="myInput">

<script>
  document.getElementById("myInput").readOnly = true; 
</script>

Output: