cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Reset button to clear fields on form

Jump to solution

Greetings,

 

I am looking for a way to create a custom button that when pressed will clear or reset all (and/or selected) fields in the form.

 

I found a snippet of JavaScript that I hoped would work but it is not clearing the fields.

 

I've created a simple form with 3 fields; a single line text, a multi line text and a person/group field Named NameOfBox1, NameOfBox2, NameOfBox3 respectively.

 

The code I am trying to use on client click is;

 

NWF$(document).ready(function(){ 

var obj = NWF$("#" +Choices); 

obj.change(function(){

NWF$("#" + NameOfBox1).val('');

NWF$("#" + NameOfBox2).val('');

NWF$("#" + NameOfBox3).val('');

} );

} );

Any help will be greatly appreciated.

Labels: (1)
0 Kudos
Reply
19 Replies
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

You can add a button on the form and configure it to be a Javascript button (Button action field). In the Advanced section of the button's settings, you can populate the Client click field with the following :

resetForm();

Then you can add the following javascript function in your form (in a javascript file referenced in your Nintex form or in the Custom Javascript section in the settings of the form) :

function resetForm() {

     // Reset a single line field

     NWF$("#" + NameOfBox1).val('');

     // Reset a plain text multiline text field

     NWF$("#" + NameOfBox2).val('');

     // Reset a people picker

     var peoplePickerControl = new NF.PeoplePickerApi("#" + NameOfBox3);

     peoplePickerControl.clear();

}

Do you have a rich text or plain text multiline control ?

Hope this helps

Reply
Not applicable

Re: Reset button to clear fields on form

Jump to solution

Can this be done on the SQL Request?  Essentially I have another SQL request populating one field (Customer) and they want to return back information from that SQL database with the leads for that customer

0 Kudos
Reply
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

Do you want to re-execute the SQL request after the form has been loaded ?

0 Kudos
Reply
Not applicable

Re: Reset button to clear fields on form

Jump to solution

Yes please

0 Kudos
Reply
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

Unfortunately it is not possible but I think that this feature is on the roadmap

0 Kudos
Reply
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

I am trying to clear the custom signature field only with a click of a button on desktop version of forms, which is a multiple line plain text field. When i use the code you provided me it clears the whole form. I am only using the portion of the code you have provided:

function resetForm() {

NWF$("#" + NameOfBox2).val('');}

0 Kudos
Reply
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

That's really Strange that with only this function it clears all the form.

Have you populated the Store Client ID in a Javascript variable for each control in your form? If so, have you populated a different name for each control?

0 Kudos
Reply
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

I have stored client id only for the button to clear the signature field. The multiple line plain text signature box already has client id stored on it. 

0 Kudos
Reply
Workflow Hero

Re: Reset button to clear fields on form

Jump to solution

Well, in this case it cannot be due to the following lines of code :

function resetForm() {

NWF$("#" + NameOfBox2).val('');

}

Can you try to change the name of the function to myCustomResetFormFunction?

0 Kudos
Reply