Skip to content Skip to sidebar Skip to footer

Clear Input Fields On Form Submit

I know this is continuously asked anew, and I've checked out different answers and tried different solutions but to no avail. In some cases it can be really be a case by case thing

Solution 1:

Use the reset function, which is available on the form element.

var form = document.getElementById("myForm");
form.reset();

Solution 2:

You can clear out their values by just setting value to an empty string:

var1.value = '';var2.value = '';

Solution 3:

You can access the form over the event:

e.target.reset();

Solution 4:

By this way, you hold a form by his ID and throw all his content. This technic is fastiest.

document.forms["id_form"].reset();

Solution 5:

Still using empty strings you can use:

document.getElementById("name").value = '';
document.getElementById("review").value = '';

Post a Comment for "Clear Input Fields On Form Submit"