<input type="email" id="testEmail" >
<div id="results"></div>
#testEmail {
display: none;
}
let result = document.querySelector("#results");
function divLog(s) {
result.innerHTML += s + '<br/>';
}
let emailField = document.querySelector("#testEmail");
let tests = [
"foo@foo.com",
"foo",
"goo@goo.com",
"zoo"
];
tests.forEach(t => {
emailField.value = t;
divLog(`Is ${t} a valid email? ${emailField.checkValidity()}`);
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.