@MelvinAguilar
Posted
Hello there ๐. Good job on completing the challenge !
I have some suggestions about your code that might interest you.
-
Verifying an email address in JavaScript typically involves using regular expressions or built-in functions to check if the email follows a valid format. Here's a basic example
function isValidEmail(email) { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); } // Example usage const emailToVerify = "[email protected]"; if (isValidEmail(emailToVerify)) { console.log("Email is valid!"); } else { console.error("Email is invalid"); }
- It seems that the current implementation has validations to display error messages, but there is no mechanism to remove or clear those error messages. Ideally, if a user modifies the input to correct the error, the error message should be removed.
- Directly manipulating styles in JavaScript can lead to code that is hard to maintain. Create a CSS class with the desired styles and use JavaScript to add or remove that class.
- Consider organizing your code more efficiently by moving all the document.querySelector calls outside of the event listener and assigning them to variables at the beginning.
- Additionally, if you've already obtained the element in
const firstName
, there's no need to usedocument.querySelector('.first-name')
again. You can simply use the variablefirstName
for subsequent operations.
I hope you find it useful! ๐
Happy coding!
Marked as helpful
@JulienLach
Posted
@MelvinAguilar Hello, big thanks for you reply. I will try your suggestions ! I didn't know about your last bullet point, calling variables. I will fix my code