How to clear form after submit in Javascript without using reset? (original) (raw)

Last Updated : 20 Jun, 2024

Forms in JavaScript serve to gather specific user information, essential in various contexts like recruitment or inquiry submissions. While offline forms can be freely distributed, online forms must maintain a consistent structure for all users.

After filling out a form, submission is crucial, but designers also tackle post-submission actions, such as clearing form fields without using the reset function, which we'll explore further in this section.

**Example: To demonstrate creating an HTML form using tables, assign IDs to fields like name, phone number, email, and description. Use JavaScript within a script tag to define a function, `fun()`, that resets field values to empty, ensuring data clearance without submission.

html `

Resetting the form without reset method

GeeksforGeeks

clear form after submit in Javascript without using reset
Username
Email
Ph no

`

**Output: