DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • Project 1: The Performance-First Dashboard
  • Project 2: Accessible Video Player
  • Project 3: Markdown Blog Engine
  • Project 4: Browser-Based Code Editor
  • Project 5: Multi-Tab Whiteboard
  • Project 6: Infinite Scroll Image Gallery
  • Project 7: Recipe Optimizer & Converter
  • Project 8: Budget Tracker with Charts
  • Project 9: Typing Speed Test
  • Project 10: Weather App with Time-Travel
  • Project 11: CSS Grid Layout Builder
  • Project 12: Password Vault (Frontend Only)
  • Project 13: Kanban Board (Trello Clone)
  • Project 14: Quiz App with Leaderboard
  • Project 15: Habit Tracker (GitHub Style)
  • Project 16: E-commerce Product Page
  • Project 17: Unit Converter (Expert Mode)
  • Project 18: Music Visualizer
  • Project 19: Flashcard Learning App
  • Project 20: Custom Form Validator
  • Project 21: Virtual Terminal
  • Project 22: Pomodoro Timer (Focus Pro)
  • Project 23: SVG Path Editor
  • Project 24: Movie Database Matchmaker
  • Project 25: Interactive Resume / Portfolio
  • Project 26: Recipe Scraper UI
  • Project 27: Crypto Tracker (Real-Time)
  • Project 28: Find My Pet (PWA)
  • Project 29: Markdown-to-Slide Tool
  • Project 30: Browser Health Dashboard
← From Beginner to Expert in Fundamentals of Frontend

Project 20: Custom Form Validator

40 min read
Regex ValidationAsync ValidationMulti-Step FormsError AccessibilityDebouncingFocus Management

📋 Project Brief

Build a complex multi-step onboarding form with custom validation — no validation libraries allowed. This project covers regex-based validation, asynchronous validation (e.g., checking username availability), accessible error handling, and a progress stepper UI.

✅ Feature Requirements

Feature 1: Custom Regex Validation

Acceptance Criteria:

  • Email: Must match RFC 5322 simplified pattern
  • Password: Minimum 8 characters, at least one uppercase, one lowercase, one number, one special character
  • Phone: Support international formats (+1, +44, +91, etc.)
  • URL: Must start with http:// or https://
  • All patterns must be written from scratch — no libraries
  • Validation runs on blur and on submit

Feature 2: Async Validation

Acceptance Criteria:

  • "Username" field checks availability via a simulated API call (setTimeout + random result)
  • Show a loading spinner while checking
  • Debounce the check: only trigger after 500ms of no typing
  • Show ✅ "Available" or ❌ "Taken" next to the field
  • The form cannot be submitted while async validation is pending

Feature 3: Progress Stepper

Acceptance Criteria:

  • Steps: 1. Personal Info → 2. Account Setup → 3. Preferences → 4. Review & Submit
  • A visual stepper at the top shows current step with completed steps checked
  • "Next" button is disabled until the current step's fields are valid
  • "Back" button returns to the previous step with data preserved
  • Step 4 (Review) shows a summary of all entered data

Feature 4: Error Summary

Acceptance Criteria:

  • On submit attempt with errors, an error summary appears at the top of the form
  • The summary lists all errors with links that focus the corresponding field when clicked
  • The summary has role="alert" so screen readers announce it immediately
  • Individual fields show inline error messages below them
  • Error messages are clear and specific (not just "Invalid field")

Feature 5: Password Visibility Toggle

Acceptance Criteria:

  • An eye icon toggles the password field between type="password" and type="text"
  • The icon changes to reflect the current state (eye open/closed)
  • The toggle button has an accessible label: "Show password" / "Hide password"
  • Focus must remain on the password field after toggling

📊 Validation Rules

FieldRulesError Message
Full Name2-50 characters, letters and spaces only"Name must be 2-50 characters, letters only"
EmailValid email format"Please enter a valid email address"
Password8+ chars, 1 upper, 1 lower, 1 number, 1 special"Password must include uppercase, lowercase, number, and special character"
Confirm PasswordMust match Password"Passwords do not match"
Username3-20 chars, alphanumeric + underscore, available"Username is taken" or "3-20 characters, letters/numbers/underscore"
PhoneValid international format"Please enter a valid phone number"
Date of BirthMust be 13+ years old"You must be at least 13 years old"

🧪 Testing Checklist

  • Unit test every regex pattern with valid and invalid inputs
  • Unit test age calculation from date of birth
  • Unit test debounced async validation
  • Integration test: complete all steps and submit successfully
  • A11y: error summary announced by screen reader; focus management on step change

🚀 Stretch Goals

  • Add form data auto-save to localStorage (resume later)
  • Implement CAPTCHA integration
  • Add conditional fields (e.g., "Company Name" only if "Profession" = "Employed")
  • Create an animated success page after submission

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.