0

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101
JoeO
  • 79
  • 1
  • 3
  • 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? – Barmar Jan 16 '23 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. – JoeO Jan 17 '23 at 02:33

0 Answers0