Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
How i can delete span text made in js?

How can I delete or hide the text while somebody in my form input in the second time give correct data? I mean when somebody on first time give incorrect the text will display "First Name cannot be empty!" and then give correct data and the text is there but invisible.

        errorFunc(fname, 'First Name cannot be empty!')
    } else {
        successFunc(fname)
    }

    if (lastName === '') {
        errorFunc(lname, 'Last name cannot be empty!')
    } else {
        successFunc(lname)
    }

function errorFunc(req, message) {
    const formControl = req.parentElement;
    const span = formControl.querySelector('span');
    span.innerText = message;
    req.classList.add('error');
    span.classList.add('error-text');
    req.classList.remove('success');
}

function successFunc(req) {
    const formControl = req.parentElement;
    const span = formControl.querySelector('span');
    req.classList.add('success');
    req.classList.remove('error')
    span.classList.remove('error-text')
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have 2 options:

  • You can remove the span with .remove() function.

    span.remove()
    
  • Also you can maintain the span element but remove text.

    span.innerText = ""
    
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda