Language

Readonly Attribute

The readonly attribute prevents the user from changing the value of the <input> element. The user can only read and view the value of the element.

Since the element's value cannot be changed, there is no need to validate its value.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form>
        <label for="full-name">Full Name</label>
        <input type="text" id="full-name" value="John Smith" readonly> 
        <br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>