Design comparison
Community feedback
- @BrandonJr20Posted 11 days ago
Una posible funcionalidad, piensa para que funcionara el boton de descartar subscripcion, ya que queda sin funcionalidad alguna, podrias implentarlo para regresar al formulario o redireccionarlo a otro sitio.
Te hace falta agregar la validacion desde la parte del javascript, esto agrega un nivel de seguridad para que tu sitio no sea tan vulnerable.
Marked as helpful0@ChikairoPosted 11 days ago@BrandonJr20 alright thank you. Pls can you send me a link to your solution so I can learn from your code.
0@BrandonJr20Posted 11 days ago@Chikairo Si claro, te comparto el script document.addEventListener('DOMContentLoaded', () =>{ const emailInput = document.getElementById('email') const errorEmailInput = document.getElementById('errorEmail') const vistaFormulario = document.getElementById('vistaFormulario') const vistaSucessfull = document.getElementById('vistaSucessfull')
emailInput.addEventListener('keyup', validateEmail) function validateEmail(){ const value = emailInput.value const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ if(!emailPattern.test(value)){ errorEmailInput.textContent = 'Valid email required' }else{ errorEmailInput.textContent = '' } } document.getElementById('form').addEventListener('submit', (e) => { e.preventDefault() validateEmail() if(errorEmailInput.textContent){ alert('Corrige los errores antes de enviar') }else{ alert('Registro exitoso') window.location.href = "sucefull.html" document.getElementById('email').value = '' } })
})
y tambien el enlace a mi github https://github.com/BrandonJr20/Frontend-Projects/tree/main/newsletter-sign-up-with-success-message-main
0
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