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

128
Vistas
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 Respuestas
Responde la pregunta

0

Just wrap them to one function:

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

0

You can call functions inside of functions…

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

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

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 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