web 1st assign
web 1st assign
Assignment # 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sample Form</title>
</head>
<body>
<fieldset>
<legend>User Information</legend>
<label for="email">Email:</label>
<label for="password">Password:</label>
</fieldset>
<fieldset>
<legend>Preferences</legend>
<option value="english">English</option>
<option value="spanish">Spanish</option>
<option value="french">French</option>
</select>
<fieldset>
<legend>Interests:</legend>
</fieldset>
<fieldset>
<legend>Gender:</legend>
</fieldset>
</fieldset>
<fieldset>
<legend>Comments</legend>
</fieldset>
<button type="submit">Submit</button>
</form>
</body>
</html>
Explanation of Form Elements and Attributes
<form> Element:
action="/submit-form": Specifies the URL where the form data will be sent.
method="POST": Indicates that the form data will be sent using the POST method, suitable for
sensitive data (like passwords).
enctype="multipart/form-data": Necessary for file uploads, ensuring that the file data is
properly encoded.
<label> Tags:
Associating labels with inputs improves accessibility and usability; screen readers can read the
label when the associated input is focused.
Input Types:
Number: Validates that only numbers are entered and sets boundaries with min and max.
File: Allows users to upload images, with an accept attribute to restrict file types.
Select Dropdown:
Checkboxes:
Radio Buttons:
Allows a single selection for gender.
<textarea>:
Client-side Validation:
HTML5 attributes like required, pattern, maxlength, and minlength provide basic validation
before submission, enhancing user experience by catching errors early.
Server-side Validation:
Important for security, as client-side checks can be bypassed. Always validate and sanitize
inputs on the server to protect against malicious data.
Conclusion:
This form structure promotes usability, accessibility, and security, effectively utilizing both
client-side and server-side validation techniques,