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

173
Vistas
2 functions in the same button during submitting the form

I want to submit a form , the story that what i want exactly is when i click on the button submit" if there was an error(fields not filled) , show me message and go to a specific "id" section in the body otherwise it will jump automatically to new section tag,

I have applied that on a the button submit like that :

  <script>
    function validate() {
    if (form.errors){
      return alert('{{ message }}');
      document.getElementById('firstsectionid').scrollIntoView();
    } 
    else{
      document.getElementById('nextsectionid').scrollIntoView();
}

   </script>

code button submit:

  <button class="floated" href='#nextsectionid' onclick="validate()">Next</button>

But it doesn't give any result , help please. thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

  <script>
    function validate() {
    if (form.errors){
      return alert('{{ message }}');
      // the line below will never run with a 'return' above it.
      document.getElementById('firstsectionid').scrollIntoView();
    } 
    else{
      document.getElementById('nextsectionid').scrollIntoView();
}

   </script>

try this

  <script>
    function validate() {
    if (form.errors){
      document.getElementById('firstsectionid').scrollIntoView();
      return alert('{{ message }}');
    } 
    else{
      document.getElementById('nextsectionid').scrollIntoView();
}

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