Question: 8.18 LAB: User registration and validation with regex In this lab, you will use regular expressions with JavaScript to validate a user registration form. Error
8.18 LAB: User registration and validation with regex
In this lab, you will use regular expressions with JavaScript to validate a user registration form. Error messages will be displayed at the bottom of the form, as shown below.
Complete checkForm() in register.js to verify that the user-provided information is valid.
If form validation errors exist:
Display the formErrors
Display each of the associated error messages in the formErrors
Add the error class to each element with invalid input
If no form validation errors exist:
Hide the formErrors
Remove the error class from all test, email, and password elements
Perform the following form validations in the order provided and display all error messages that apply:
Ensure a full name with a length greater than or equal to 1 was provided
Otherwise, display "Missing full name."
Ensure that an email address was provided and that the email address matches the regular expression: /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}$/
Otherwise, display "Invalid or missing email address."
Ensure the password has 10 to 20 characters
Otherwise, display "Password must be between 10 and 20 characters."
Ensure the password contains at least one lowercase character (use a regular expression)
Otherwise, display "Password must contain at least one lowercase character."
Ensure the password contains at least one uppercase character (use a regular expression)
Otherwise, display "Password must contain at least one uppercase character."
Ensure the password contains at least one digit (use a regular expression)
Otherwise, display "Password must contain at least one digit."
Ensure the password and confirmation password matchOtherwise, display "Password and confirmation password don't match."
Test your solution by typing invalid data in each input and pressing the Register button. Verify a red border surrounds the input with invalid data and the correct error message displays.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
