so I'm using the SweetAlert2 to validate form entries(if its empty). However my problem is here:
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>
If I don't use e.PreventDefault() then my form will get submited. If I change "click" to "submit" my form will get submited.
I tried jQuery, document by id and submiting nothing works. My goal is to add user before the "User added succesfully" message pops up.
So far