Display meaningful HTML5 validation error message

Created on 16 March 2017, over 7 years ago
Updated 22 April 2024, 6 months ago

Problem/Motivation

This is a follow up of 🐛 Display meaningful error messages according to the link type Needs work
The default HTML5 validation error for url input type is set by the browser, and most of them just display a message that does not really help the user to figure out how to correct an invalid link such as example.com, which is missing the protocol. In Firefox, the default validation error message is Please enter a URL.

Note: this validation is done only for LinkItemInterface::LINK_EXTERNAL, external links only.

Proposed resolution

Add a custom validation error message, such as Enter a full URL, such as http://example.com

Remaining tasks

User interface changes

Changes the HTML5 validation error message for external links.

API changes

none

Data model changes

none

Screenshots

Default validation error message:

Custom validation error message:

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Link 

Last updated 8 days ago

Created by

🇧🇷Brazil Mac_Weber

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada SKAUGHT

    re: needs work:
    - overall, summary should be updated to include both internal and external. This phase should be tied to the field instance in use.
    - js in patch is using direct oninvalid attribute.
    - scope too narrow, see below.

    #24.2 and #24.3 are not addressed.

    A behavior for Drupal js seem like a better way to get this connected thru all form items. certainly Drupal.t() and plural can be handled there.
    The scope is looking at Link, but is really this is where this new library should be able to continue to connect around form items that have 'required_error' to have a data attribute added into the form item render and use those strings for this level of (pre-submit) javascipt messaging to work more ideally.

Production build 0.71.5 2024