input validation html code example

Example 1: filled input in form

<input type="text" value="default value">

Example 2: name validation html

<input type="text" pattern="[a-zA-Z'-'\s]*">

Example 3: html form validation

<form action="">
    <label for="name">Username</label>
    <input id="name" type="text" required />
    <label for="Email">Email</label>
    <!-- The required attribute will prompt the user to make sure  -->
    <!-- the fields are not empty, and that the email is formatted correctly -->
    <!-- if you want to use custom validation you should use regex in JavaScript -->
    <input id="Email" type="text" required />
</form>