@MelvinAguilar
Posted
Hello there ๐. Good job on completing the challenge !
-
Your form validation logic is solid, but for better code organization, consider separating your CSS styles from the JavaScript logic. Create a CSS class with the desired styles, and then use JavaScript to add or remove that class. This helps maintain a cleaner structure and makes it easier to manage styles.
Here's an example:
CSS:
.error { border: 1px solid red; } .success { border: 1px solid green; }
Your JavaScript
if (!emailField.value.match(/^[A-Za-z\._\-0-9]*[@][A-Za-z]*[\.][a-z]{2,4}$/)) { emailError.classList.add('error'); return false; } else { emailError.classList.remove('error'); emailField.classList.add('success'); return true; }
Happy coding!
Marked as helpful
@Manifoldbit
Posted
@MelvinAguilar .. Thanks so much.. i really appreciate.. i will make adjustments