JSFiddle - React, Tailwind, and code Playground
HTML
<input type="email" name="foo" id="bar" value="nope...">
<button type="button" id="check">check mail</button>
JavaScript
var check = document.getElementById("check");
var email = document.getElementById("email");
check.addEventListener("click", function (e) {
try {
if (email.validity.typeMismatch) {
email.setCustomValidity("custom message can be typed here");
} else {
email.setCustomValidity("");
}
} catch(err) {
alert(err.message);
}
});