These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

clear field when check box is selected

keippela
Registered: Dec 9 2010
Posts: 1

I'm trying to clear a series of fields if a user selects a check box. I am very new to using Javascript so I'm not sure where to start.... any ideas out there? thanks!

My Product Information:
Acrobat Pro 10.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can put this code as the check-box's custom validation script:

if (event.value=="Yes") {
this.getField("field1").value = "";
this.getField("field2").value = "";
this.getField("field3").value = "";
// ... etc
}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
If the form was created in Acrobat, then you can use the 'this.resetForm' method

if(this.getField(event.target.name).value == "Yes") {
this.resetForm(["Field1", "Field2", "Field3"]);
}

or

if(this.getField(event.target.name).value == "Yes") {
// array for field names
var aFieldNames = new Array();
// add field names to array
aFieldNames[0] = "Field1";
aFieldNames[1] = "Field2";
aFieldNames[2] = "Field3";
// clear the specified fields
this.resetForm(aFieldNames);
}

In LiveCycle Designer you can use the 'xfa.host.resetData()"

George Kaiser