-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interest
Description
What problem are you trying to solve?
Today, web developers must write custom JavaScript to validate form inputs such as names, emails, phone numbers, passwords, and password confirmation.
This adds complexity, increases page load, can create inconsistencies across browsers, and is especially challenging for beginners.
A native validation attribute on elements would allow declarative validation, enabling the browser to automatically handle error messages, real-time feedback, and optional features like password strength or visibility toggle.
Live Demo: https://mtechamit.github.io/adaptive-form-validation/
GitHub Repository: https://github.com/mtechamit/adaptive-form-validation
What solutions exist today?
- Custom JS validation libraries (e.g., Parsley.js, Formik)
- HTML5 built-in attributes (required, type="email", pattern)
- Browser inconsistencies for complex validations (password strength, confirm password, international phone numbers)
- While these work, they require extra JS/CSS, are not fully standardized, and often introduce boilerplate code.
How would you solve it?
Introduce a standardized validation attribute for elements:
- Browser validates automatically based on the value of validation (e.g., name, phone, email, password, confirm)
- Generates native error messages if input is invalid
- Optional visual enhancements: password strength bar, show/hide toggle
- Fully backward compatible: unsupported browsers ignore the attribute
<input type="text" validation="name" placeholder="Full Name">
<input type="tel" validation="phone" placeholder="+1 123 456 7890">
<input type="password" validation="password" placeholder="Password">
<input type="password" validation="confirm" for="password" placeholder="Confirm Password">
Anything else?
Benefits
- No JS required → lightweight, faster, and more secure
- Consistent validation across all browsers
- Integrates with browser features: autofill, password managers, accessibility
- Easy for beginners
- Reduces development time and errors
- Extensible for future custom types
Metadata
Metadata
Assignees
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interest