Practice & Assessment
Test your understanding of Real-World Validation Patterns
Multiple Choice Questions
6Why is a pragmatic email regex better than strict RFC 5321 compliance for form validation?
When should you use the URL constructor instead of a regex for URL validation?
What does /^\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/ match?
What does /^4/ tell you about a credit card number?
Why should regex credit card validation always be paired with the Luhn algorithm?
What is the advantage of compiling regex patterns once at module load time?
Coding Challenges
1Form Validation Suite
Write a validateForm(fields) function that accepts an object with any combination of these keys: email, phone, zip, url.
Mini Project
Contact Form Validator with Live Feedback
Build a self-contained HTML+JS page with a contact form containing: name, email, phone, website URL, and message.
