The purpose of this assignment is to provide students with practical experience in implementing basic form validation using JavaScript. Students will learn how to ensure that user inputs meet specified criteria before form submission.
In this hands-on exercise, students will create a simple web form and implement client-side validation using JavaScript. The form should include various input types, such as text fields, email, password, and select/dropdown menus. The validation script should check for correct input formats, required fields, and any other specified conditions before allowing the form to be submitted.
Create a registration and login form
Form Fields: Name (text field) Email (email field) Password (password field) Confirm Password (password field) Age (number field) Gender (radio buttons) Country (select/dropdown menu) Terms and Conditions (checkbox) Submit Button: A button to submit the form.
Form Fields: Email (email field) Password (password field) Login Button.
Required Fields: Ensure that all fields marked as required are not empty. Email Validation: Check that the email address is in the correct format (e.g., user@example.com). Password Validation: Ensure the password is at least 8 characters long. Ensure that the "Confirm Password" field matches the "Password" field. Number Validation: Ensure the age entered is a valid number and falls within a reasonable range (e.g., 18-100). Checkbox Validation: Ensure that the "Terms and Conditions" checkbox is checked before form submission. Error Messages: Display clear and concise error messages near the relevant fields if validation fails.