Used HTML and CSS without JavaScript

Solution retrospective
I could not add the JavaScript code for this website. It will be much appreciated if you can help me with this.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @Wesleys-hub
Hey man, i would sugget adding an id to the form and the input. Make the styles following the design (active-states) image and add them when the user fills in either a correct or a wrong input
// get the form and input const form = document.getElementById("form"); const email = document.getElementById("email");
// add event listener to button form.addEventListener("submit", (e) => { e.preventDefault(); // get the value of the input const emailVal = email.value;
let validateEmail = () => { let filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; // if not correct add error class and remove correct class if (!filter.test(emailVal)) { form.classList.add("form-error"); form.classList.remove("form-correct"); // if correct add correct class and remove error class } else { form.classList.remove("form-error"); form.classList.add("form-correct"); } }; validateEmail(); });
- @just-a-devguy
What you mean by not being able to add the js. Is it that you're not understanding what's required or is it that you understand what's expected but not how to do it?
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord