By completing this exercise, students will be able to:
- Understand basic form elements:
<form>
,<input>
,<textarea>
,<select>
,<button>
- Set
name
,type
,placeholder
, andvalue
attributes correctly - Use form submission with the
action
andmethod
attributes - Group fields using
<fieldset>
and<legend>
Instructions:
- Create an HTML file named
contact-form.html
. - Create a form that includes the following inputs:
- Full Name β Text input
- Email Address β Email input
- Message β Textarea with 5 rows
- Submit β Button
- Set the
action="#"
andmethod="post"
attributes in the<form>
tag. - Add appropriate placeholders and labels.
Instructions: Create another form section that includes:
- Date of Birth β
type="date"
- Gender β Radio buttons (Male, Female, Other)
- Subscribe to Newsletter β Checkbox
- Password β
type="password"
- Confirm Password β
type="password"
Instructions:
Add a dropdown (<select>
) for selecting your Country, with the following options:
- Cambodia
- Thailand
- Vietnam
- Laos
Label this field properly and make it required.
Instructions:
Group related fields using <fieldset>
and <legend>
. For example:
- Contact Info
- Account Info
Design a full registration form including:
-
Name
-
Email
-
Phone Number
-
Country (dropdown)
-
Gender (radio)
-
Newsletter (checkbox)
-
Password and Confirm Password
-
Use placeholders, labels, and required fields
-
Include a Reset button
-
Use CSS to style the form nicely (optional)
Add validation rules:
- Email should be in email format
- Password and Confirm Password must match
- All required fields must be filled
π Reference: