<div class="container">
  <input type="email" id="emailField">
  <br />
  <button id="button">Check validation</button>
  <div id="response"></div>
</div>
* {
  margin: 0;
  padding: 0;
  font-family: Roboto,"Helvetica Neue",Arial,sans-serif;
}
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100vh;
  background: #F3CA40;
}
input {
  padding: 10px;
}
button {
  padding: 10px;
  background: #F08A4B;
  outline: none;
  apearance: none;
  border: 1px solid #F2A541;
  color: #fff;
}
#response {
  margin-top: 50px;
  font-size: 24px;
  text-align: center;
}
const emailField = document.getElementById("emailField");
const button = document.getElementById("button");
const response = document.getElementById("response");

button.addEventListener("click", function () {
  const email = emailField.value;
  if (validateEmail(email)) {
    response.innerHTML = "Hiya Cowboy, this email will work for us 🤠";
  } else {
    response.innerHTML = "Sorry, this email is not cool enough 😩";
  }
});

function validateEmail(email) {
  const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  return re.test(String(email).toLowerCase());
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.