To set an element to read-only, use the readonly attribute. You can try to run the following code to implement readonly attribute −
Example
<!DOCTYPE html> <html> <body> <h2>Login</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 = "Submit"> </form> </body> </html>