Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

164
Vistas
Code works perfectly on codepen but not in webstorm

The code that am trying in codepen worked, the same one does not work in webstorm. Nothing seem to work no error showing when clicking on button,

Example

const email = document.querySelector('.user-input');
const submit = document.querySelector('.btn0');
const error = document.querySelector('.mail-error');

const showError = () => {
error.style.display = 'block';
};

if (submit) {
  submit.addEventListener('click', (e) => {
    e.preventDefault();
    if (!email.value.match(/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/)) {
       return showError();
    }
    document.getElementById("main0").style.display = "none";
    document.getElementById("main1").style.display = "block";
  });
}
<div id="main0">
  <input class="user-input" id="input-id" placeholder="Email" onblur="">
  <p class="mail-error" style="display: none;">Please enter valid email</p>
  <div class="btn0" id="btn0id" onclick="">NEXT</div>
</div>
<div id="main1" style="display:none;">
  <p> You now have access. <p>
</div>

about 4 years ago · Santiago Gelvez
2 Respuestas
Responde la pregunta

0

document.addEventListener("DOMContentLoaded", function(event) {
    // put your code here
});
about 4 years ago · Santiago Gelvez Denunciar

0

Fixed by adding "defer" when linking to the external script file, now everything works fine.

<script src="script.js" defer></script>
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda