Clearing data from UIForm

Katrina Miday asked on October 23, 2018 13:51

Hello! Does anyone happen to know how to clear the UIForm via a "cancel" button without refreshing the page?

Recent Answers


Arun Kumar answered on October 23, 2018 14:13 (last edited on October 23, 2018 14:16)

You can use simple jQuery on Cancel button click to clear the form

$("#btnCancel").click(function(){
   $("#form")[0].reset();
});

Or you can add a new button with type reset or change Cancel button type to reset if you are not doing any other operation with Cancel button

<button type="reset" value="Cancel">Cancel</button>

0 votesVote for this answer Mark as a Correct answer

Katrina Miday answered on October 23, 2018 14:24

Thank you for the response. I am performing other operations with the cancel button though, hiding the form and resetting a list of items.

0 votesVote for this answer Mark as a Correct answer

Arun Kumar answered on October 23, 2018 14:25 (last edited on October 23, 2018 14:26)

Then use first approach using jQuery. If you already have click event attached to your cancel button then add form reset code at the end of the click function

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.