Problem/Motivation
Hi,
We had an accessibility audit and one of the issues was that the error message for email fields was not helpful enough and should contain something about the format it expects. Personally I disagree and think the message is good enough, but perhaps it is worth to look into.
I decided to create a patch instead of overriding the email class because the latter would not keep track of any possible future changes to the Email field.
Sincerely,
Dagomar
Proposed resolution
The current email field validation error message doesn't contain anything about the email format, So add a sample format in the error message
Current error message
"The email address abc.@in is not valid."

Proposed error message
"The email address abc.@in is not valid. Use the format user@example.com."

| Comment | File | Size | Author |
|---|---|---|---|
| #20 | 3114016-20.patch | 1.65 KB | ranjith_kumar_k_u |
| #20 | interdiff_10-20.txt | 808 bytes | ranjith_kumar_k_u |
| #20 | 3114016-20-test-only.patch | 956 bytes | ranjith_kumar_k_u |
| #18 | After Patch.png | 13.95 KB | prasanth_kp |
| #18 | Before Patch.png | 10.71 KB | prasanth_kp |
Comments
Comment #2
dagomar commentedComment #3
idebr commentedComment #4
joachim commentedOne problem with this is that email addresses can be more complex than that.
For instance, you can have 'user+suffix@example.com'.
Comment #6
abhijith s commentedApplied patch #2 on 8.9.x and it works fine.
Before patch:

After patch:
RTBC +1
Comment #7
gauravvvv commentedPatch #2, works fine to me. Moving to RTBC.
Comment #8
catchInstead of 'it should look like example@domain.com' could we use something like 'use the format user@example.com'.
Also normally with examples we use example.com which is reserved. domain.com is an actual valid domain that points to a website - so we shouldn't use that.
Comment #9
richa_porwal commentedComment #10
richa_porwal commentedHi Team,
I have created patch for the above problem motivation. Need review
Comment #11
richa_porwal commentedComment #12
richa_porwal commentedComment #16
Manibharathi E R commentedApplied patch #2 on 9.4.3 and it works fine.
Before Patch Apply
After Patch Apply
Comment #17
gaurav-mathur commentedpatch #10 successfully applied on drupal 10.1.0-dev and 9.4.x Which I showed by screenshot.
Thanks and Regards .
Comment #18
prasanth_kp commented#10 Patch Applied on 10.1.x-dev and it works fine for me.
Comment #19
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Even though this is a task think it could use test coverage for the change.
Comment #20
ranjith_kumar_k_u commentedAdded tests, please review
Comment #21
ranjith_kumar_k_u commentedComment #22
smustgrave commentedTests look good
This could use an issue summary though for what the message was updated to and why. Current IS mentions accessibility issue but how does this now pass?
Comment #24
yoroy commentedThis is ok to add, but minor indeed. No need for an explicit usability review & signoff. Go for it!
Comment #25
ranjith_kumar_k_u commentedComment #26
smustgrave commentedIn that case the change looks good and appears correctly.
Comment #28
quietone commentedI'd rather this use 'foo' instead of 'abc' but it has not thrown any spelling errors.
Thanks everyone! Our UI is a wee bit better.