Łukasz W.
Łukasz W.

Reputation: 9755

How to retrieve error message set with setCustomValidity?

I'm setting custom validity using HTML5 Constraints API like this

inputElement.setCustomValidity('This is custom error message')

Then I'm trying to retrieve the value afterwards, but it's not present in any of ValidityState object fields when I'm listing them. It just sets customError to true, but the message is not in there.

How can I retrieve this message from the input element?

Upvotes: 2

Views: 763

Answers (1)

user9607263
user9607263

Reputation:

You can retrieve it with inputElement.validationMessage.

Upvotes: 9

Related Questions