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

123
Visualizações
HTML check if data were sent instead of using onclick

I'm using onclick on a submit button to make a loading element with javascript on the page before retreiving data from an extract.

However I added a pattern on some input on the form associated with this submit button and the problem I have is that, if the pattern doesn't match (the form doesn't send wrong data, which is good) but this trigger the onclick event generating my loading element for nothing, and that could confuse users.

How can I know for sure that the information of my form has been sent allowing me to start my loading function?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try something similar:

<button type="submit" onclick="handleSubmit(event)">Submit</button>

In your JS code:

function isFormValid() {
    // Put here the logic of form validation, which return a boolean value
}

function handleSubmit(event) {
    if (!isFormValid()) {
        event.preventDefault();
        return;
    }
}
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