Để đặt phần tử chỉ đọc, sử dụng thuộc tính readonly. Bạn có thể chạy mã sau để triển khai thuộc tính readonly:
Ví dụ
<!DOCTYPE html>
<html>
<body>
<h2>Đăng nhập</h2>
<form action="/new.php">
<input type="text" value="Amit" name="sname" readonly/><br>
<input type="password" name="password"> <br><br>
<input type="submit" value="Gửi">
</form>
</body>
</html>