Design comparison
SolutionDesign
Solution retrospective
Today I did a Newsletter Sign-up Form with a stylish success message. Learn how to structure the HTML markup, style the form elements with CSS for a RESPONSIVE DESIGN and implement simple EMAIL VALIDATION with JavaScript functionality to display a success message upon successful submission (:
Community feedback
- @matiasluduena23Posted 12 months ago
Hi ULISES! Good work! Just one recommendation that might help you in this and future projects.
- You need to validate your input with javascript.
Something like this
function validInput(input) { if(input.value.trim() === "") { //add error class here "can't be blank" }else i(!validateEmail(input.value)){ // add error class here "not valid email" } } //function to validate the email const validateEmail = (email) => { return String(email) .toLowerCase() .match( /^(([^<>()[\]\\.,;:\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,}))$/ ); };
You can make a show error function to pass the message to the function and show the error.
Hope this help you.
Good code!
Matias
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin 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