lukasdevit / newsletter-sign-up

https://newsletter-sign-up-blue-two.vercel.app
0 stars 0 forks source link

Email statement. #1

Closed lukasdevit closed 12 months ago

lukasdevit commented 12 months ago

Fix, so user see his email in the successful message popup. Fix FrontendMentor warnings.

lukasdevit commented 12 months ago

More info, coppied from Front Mentor comment:

"Hi, I'd say "maybe" to too complicated JS? Probably putting it in one file would improve readability and maintainability. Also, you have duplicate code - page.js and newsletterFormSignIn appear to be the same file with different names. One thing - you can hide the success message using absolute positioning and moving it offscreen to avoid writing a bunch of html with your JS and that would simplify things a lot. Another thing I'd point out is that you can simplify your validation - you have your input set to type email and you made it required, so you don't need to test against any regex or anything. You can use the built-in Constraint Validation API. So you'd test input.validity.valid which returns a boolean indicating if it is violating any constraints - in this case missing or not an email. You could test further as validity returns a validity state (eg typeMismatch or valueMissing), but in this case you don't need to get more detailed since you're setting the same error message no matter if empty or not an email. Hope this is helpful."