How to reset form after Ubmit?

Asked

Viewed 129 times

1

have tried onsubmit="this.submit(); this.reset(); return false;" however it sends a form Azio to the email, already tried

echo "<script>alert('Enviado com sucesso!');history.back();</script>"; 
echo ' <script>document.location.reload();</script>'; 

but the form remains completed , have tried document.nome_do_form.reset(); however it does not find the form to reset (I believe) the only one that gave was the onsubmit however the empty form does not use anything

  • 1

    Samuel, how are you submitting the form? if it is via AJAX then it is better to do it there inside the complete. If it is not via AJAX then the page loads again and the form comes empty right?

  • Can Samuel answer the question I wrote here? I would also like to answer but I need you to answer that question.

1 answer

3

Utilize document.getElementById to find the form:

<form id="formulario" onsubmit="document.getElementById('formulario').reset();return false">
    <input type="text" name="email" value="">
    <input type="password" name="password" value="">
    <input type="submit">
</form>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.