The HTMLInputElement.setCustomValidity() method sets a custom validity message for the element.
HTMLInputElement.setCustomValidity()
MDN Reference