About this article
This article was created using an automated generation workflow leveraging generative AI. Implementation details from official documentation and fixed training materials were verified to outline operational and technical constraints.Verification status: 📘 Official information and implementation cross-checked. Browser physical devices not verified.
The location to fix differs depending on whether the email address field is empty or formatted incorrectly. We retrieve the reasons from the browser, divided into two categories.
- Terminology to know first
- Thinking with a branching flowchart
- Operating the live demo
- Key points of the code
- When using it in production
- Compare the three states of the input field
- required and type are different conditions
- It is not known whether the email address actually exists
- Do not end input validation at the screen level
- Validation Scope
- References
- GitHub Sample
Terminology to know first
Constraint validationis a feature that checks whether input satisfies the conditions.
Format mismatchis a state where the entered value differs from the requested format.
Thinking with a branching flowchart
Check for blank fields using diamonds. The next step changes depending on the result.
flowchart TD
A["メール欄を確認"] --> B{"空欄?"}
B -- "はい" --> C["入力が必要と表示"]
B -- "いいえ" --> D["メール形式を確認"]
Operating the live demo
Try blank, abc, and demo@example.test.
How to read results
Missing inputs and format mismatches appear as separate reasons.
The browser checks and determines based on the format. Whether the recipient address actually exists cannot be determined from this validation.
Key points of the code
Specify type=email and required to check validity.valueMissing and validity.typeMismatch.
The implementation can be viewed in the Implementation Code section of the demo screen.
When using it in production
Even when validating on the screen, verify the same assumptions on the receiving end.
Compare the three states of the input field
Clicking the execute button creates an input field for an email address. Since the initial value is abc, the results panel is expected to display false for empty, true for format mismatch, and false for pass. Next, clear all characters from the generated input field, representing a state where no value is entered rather than a format mismatch. Finally, enter demo@example.test to see if it passes format validation. Since a fictitious address is used, no email will be sent.
| Input | Empty | Format Mismatch | Pass |
|---|---|---|---|
| Empty | true | false | false |
| abc | false | true | false |
| demo@example.test | false | false | true |
The table shows expected results derived from HTML constraints and fixed implementations, not actual measured browser values. We compare the actual result columns. For example, if the input is incomplete, provide guidance so the user can continue correcting it. It is important that users understand why processing cannot continue before submitting.
required and type are different conditions
The learning material creates an input field with type=email and sets required=true. required indicates that input is necessary, while type=email adds conditions regarding the format of the entered value. Either one alone does not necessarily fulfill the objective. For optional email fields, a design that allows blank fields while checking the format of entered values is also possible. Whether a field is required is determined by business requirements.
From JavaScript, you can check the reasons using valueMissing and typeMismatch included in ValidityState. valid indicates that no applied constraints have been violated. This tutorial reads them for each input event and displays the results in the results column. This differs from processing that triggers an actual form submission to display errors. For example, if you add another pattern attribute or custom constraints, the reasons why valid becomes false will also increase. These two reasons alone cannot determine all form anomalies.
It is not known whether the email address actually exists
HTML email format validation does not prove the existence of the recipient, deliverability, ownership by the user, or organization-approved domains. Distinguish between formats accepted by the browser and conditions accepted by the business. Since unfamiliar notations, such as local-format addresses, may be accepted, do not assume an HTML validation failure simply because it does not contain a dot. Design additional inspections according to organizational requirements.
In production input fields, for example, if a required input is missing, prompt the user to enter data; if the format is incorrect, show an example. Rather than displaying the same long explanation for every error, providing guidance corresponding to the current reason makes it easier for users to make corrections. If you provide a confirmation email feature, consider recipient verification and transmission frequency limits as a separate feature from this tutorial.
Do not end input validation at the screen level
While browser-side constraints help support input, communicated data does not always pass through those constraints. The receiving side must also inspect the same business conditions to verify authorization and storage security. When the server rejects data, display an appropriate reason on the screen. Because persistent heavy error displays during input can make operation difficult, design the timing for both mid-input guidance and submission-time inspection.
If results differ from expectations, check the type and required attributes of the input field generated after execution. Check not only the value format but also whether additional constraints have been added. There is no need to enter actual user email addresses into a public demo. Confirm error reasons and handling using dummy normal and abnormal values.
Validation Scope
Target: HTML Constraint Validation API. Static verification of MDN's type=email and constraint violation descriptions, fixed HTML required, and validity properties. Actual DOM ValidityState evaluation has not been executed. Browser compatibility, display, accessibility, and Mermaid rendering have not been verified.
References
Official Technical Documentation(Verified on November 30, 2026)
