What are Forms?
Forms in HTML allow users to input data, which can then be submitted to a server for processing.
The <form> element serves as the container for input fields, buttons, checkboxes, and more.
Each input element is defined with a specific type attribute, such as text, number, email, etc.
Input validation ensures that the data submitted through forms meets specified criteria, Example: type=`email` will only accept Email Addresses.
HTML
OUTPUT
Input Validations
Required Fields
This ensures that certain fields must be filled out before the form can be submitted.
<input type="text" id="username" name="username" required>
Data Type Validation
Verifying that the data entered matches the expected type, such as numbers, email addresses, or dates.
<input type="number" id="age" name="age" min="18" required>
Length Limits
Setting maximum and minimum lengths for input to ensure data fits within expected constraints.
<label for="password">Password (8-20 characters):</label>
<input type="password" id="password" name="password"
minlength="8" maxlength="20" required>
Pattern Matching
Checking if input matches a specified pattern, such as a valid email address or phone number format.
<label for="email">Email:</label>
<input type="email" id="email" name="email" pattern=
"[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" required>
Range Validation
Validating input against a specific range of values, like dates or numbers.
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob" max=
"2004-04-23" required>