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

126
Visualizações
How to add multiple different functions on single on submit command in javascript

I have one function for validation,and a second function for message output how I can run both of them together with a single submit click.

var myform = document.forms.hform; // hform is name

myform.onsubmit = validation;

myform.onsubmit = exercise;
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Just wrap them to one function:

myform.onsubmit = (e) => {
  validation(e);
  exercise(e);
}
about 4 years ago · Juan Pablo Isaza Relatório

0

You can call functions inside of functions…

function myFunc() {
   validation();
   exercise();
}

<button onsubmit=“myFunc”>
about 4 years ago · Juan Pablo Isaza Relatório

0

Modern javascript (by modern in this case I mean since about 2010 or even earlier) you'd use addEventListener

Like this

var myform = document.forms.hform;
myform.addEventListener('submit', validation);
myform.addEventListener('submit', exercise);
myform.addEventListener('submit', youSaidThreeFunctions);

You can add an event listener at any place in your code, so that's better than running the functions in another function

addEventListener is more flexible than using onEvent

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