Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
¿Cómo capturar el valor booleano de la función swal() y devolverlo a una función de validación que impide o permite el envío de formularios?

Tengo la siguiente estructura de código. Quiero poder capturar el valor verdadero/falso de la función swal y devolverlo a validate_empty_fields(). Sé que el siguiente código solo devuelve un objeto de promesa y swal solo le permite anidar el código verdadero/falso dentro de una función entonces. ¿Hay alguna manera de devolver el valor respectivo cuando un usuario hace clic en el botón cancelar o aceptar?

 function validate_empty_fields() { let x = document.forms["myform"]["title"].value; let y = document.forms["myform"]["description"].value; let z = document.forms["myform"]["image"].value; if(x=="" && y=="" && z== "") { swal('warning','Atleast one of the fields must be filled'); return false; } else if(x=="" || y== "" || z== "" ) { return swal({title: 'warning', text: 'Empty fields will be pushed as such', buttons:true}); } } </script> <form action="addpages.php" name="myform" method="POST" onsubmit="return validate_empty_fields()" enctype="multipart/form-data"> //input fields for title,description and image <button id="submit-btn" type="submit" >ADD PAGE</button> </form>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!