Copy link to clipboard
Copied
Hello,
I created an action button that clears a form. I used the JS below that provides the user a warning before they clear the form. However, if they select "no" it still clears it. How do I fix it?
Here's what I have so far:
if( app.alert({
cMsg: "Are you sure you want to clear this form?",
cTitle: "Reset Form Warning",
nIcon: 2,
nType: 2
}) == 4) {
this.resetForm();
}
Copy link to clipboard
Copied
There is nothing wrong with this code. If the form is still being cleared, then there is something else going on.
Are there more actions associated with the button? Or other code in the script? Maybe something leftover from your initial development?
Copy link to clipboard
Copied
Are you clearing the form and running the Javascript? If you have action to also clear form it will do both, which means clearing the form even if you press no here (and resetting it twice if you press yes). Remember you can have several events that trigger actions/scripts, so check that you don't have something happening on "Mouse Down", "Click" and/or "Mouse Up"
Copy link to clipboard
Copied
Thanks that was it. I just needed to remove the duplicate "reset a form" action. Works perfectly now.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Is there a way to target specific fields with this code? I dont want to clear everything.
I would like only to target dollar amounts in my form.
Thanks in advance
Copy link to clipboard
Copied
Sure:
this.resetForm(["Field1", "Field2", "Field3"]);