1

The HTML Constraint Validation API provides default error messages. For example, when the user enters an invalid pattern, the message below is automatically provided:

Please match the requested format.

These messages are useful because they're translated into the locale language of the user.

Can these default validation messages be accessed using client side JavaScript?

Sources:

I've read the sources listed in my original post, and cannot find a way to access these messages.

2
  • 2
    I haven't seen a way to do it. Since the browser already does the localization for you, what do you need to do with it? Commented Jan 16, 2023 at 23:28
  • 1
    Thanks @Barmar. My goal is to implement custom pattern functionality, but display the default pattern error message (same for required, etc). The answer may be to simply create invalid inputs using JS, then take the validationMessage text from them. Commented Jan 17, 2023 at 2:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.