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

243
Views
envío de formulario en eventListener ('clic') - SweetAlert2

así que estoy usando SweetAlert2 para validar las entradas del formulario (si está vacío). Sin embargo, mi problema está aquí:

JS:

 t = document.getElementById("kt_modal_new_target_submit"); e.preventDefault(), t.addEventListener("click", (function(e) { n && n.validate().then((function(g) { console.log("validated!"), "Valid" == g ? (t.setAttribute("data-kt-indicator", "on"), t.disabled = !0, setTimeout((function() { t.removeAttribute("data-kt-indicator"), t.disabled = !1, Swal.fire({ text: "User added successfuly", icon: "success", buttonsStyling: !1, confirmButtonText: "Close", customClass: { confirmButton: "btn btn-primary" } }).then((function(t) { t.isConfirmed && o.hide() })) }), 1000)) : Swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: !1, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn btn-primary" } }) })) }))

HTML:

 <form id="kt_modal_new_target_form" class="formek" method="post"></form> <button type="submit" name="addUser" id="kt_modal_new_target_submit" class="btn btn-primary"<span class="indicator-label">Add</span> <span class="indicator-progress">Adding... <span class="spinner-border spinner-border-sm align-middle ms-2"> </span> </span> </button>

Si no uso e.PreventDefault(), se enviará mi formulario. Si cambio "clic" a "enviar", mi formulario será enviado.

Probé jQuery, documento por id y enviar nada funciona. Mi objetivo es agregar un usuario antes de que aparezca el mensaje "Usuario agregado con éxito".

Hasta aquí

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!