Answer the question
In order to leave comments, you need to log in
Reset does not work on the form?
After the condition in the if condition is met, the form reset does not work. In the ife, the form code with errors is substituted, but e.target seems to be new. Why reset does not work after fixing errors is not clear.
document.addEventListener("submit", function (e) {
const form = e.target;
if (true) {
document.querySelector('.form-wrap').innerHTML = "Новая форма"
}
fetch("/" + formname, {
method: "post",
body: new FormData(form),
})
.then((res) => res.json())
.then((res) => {
if (res.status) {
form.reset;
}
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question