Copy link to clipboard
Copied
I have a pdf form where I have made it a required field to click on a yes or no button. I need one of them to be click when the person tries to save the form, but it never does. The buttons do have it so that ONLY a yes or a no can be pressed. Why can't i check for that. The js works in checking all of the other fields.
Thanks.
Copy link to clipboard
Copied
By 'buttons' you mean checkboxes or radio buttons? But it doesn't really matter since 'required' is only useful when you submit the form not when you save it, you can't stop users to save the file, you can only set up alert so when they try to save, an alert can pop to notify them to fill in the fields if they are not filled (file will still be saved).
Copy link to clipboard
Copied
What is your script?
Copy link to clipboard
Copied
Hi, for the field that is required it looks like:
When the script runs after pressing the save button, I do get error messages for all other fields except the button one:
the script is as follows:
var error=false;
var message="You must enter a value for the following required fields:\r\n";
var b1=this.getField("Name");
var b2=this.getField("Address");
var b3=this.getField("City");
var b4=this.getField("Zip");
var b5=this.getField("E-Mail");
var b6=this.getField("Signature1");
var b7=this.getField("Signature2");
var b8=this.getField("Signature3");
var b9=this.getField("USS");
if(b1==undefined || b1.value.length<1)
{
error=true;
message+="You must fill out Name before saving\r\n"
}
if(b2==undefined || b2.value.length<1)
{
error=true;
message+="You must fill out Address before saving\r\n"
}
if(b3==undefined || b3.value.length<1)
{
error=true;
message+="You must fill out City before saving\r\n"
}
if(b4==undefined || b4.value.length<1)
{
error=true;
message+="You must fill out Zip before saving\r\n"
}
if(b5==undefined || b5.value.length<1)
{
error=true;
message+="You must fill out E-Mail before saving\r\n"
}
if(b6==undefined || b6.value.length<1)
{
error=true;
message+="You must fill out SCAF COE Signature before saving\r\n"
}
if(b9==undefined || b9.value.length<1)
{
error=true;
message+="You must choose USS affiliation before saving\r\n"
}
if(b7==undefined || b7.value.length<1)
{
error=true;
message+="You must fill out CIF-SS Signature before saving\r\n"
}
if(b8==undefined || b8.value.length<1)
{
error=true;
message+="You must fill out CIF-LA Signature before saving\r\n"
}
if(!error)
{
app.alert("Please save the file.", 1); app.execMenuItem("SaveAs");
}
else
{
app.alert(message,3);
}
Copy link to clipboard
Copied
Those fields are either check boxes or radio buttons. They always have a value. The value is either the export value of the select box (default is "Yes" for check box, unless you changed it), or "Off" (when no selection is made). Therefore, value.length<1 will always return false and the condition will not run the remainder of that part of your script that flags the error. Instead of b9.value.length<1, use b9.value=="Off" (if b9 is the field you asking about).
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Use:
b9.value=="Off"
Copy link to clipboard
Copied
remove ".length". It's b9.value=="Off", as I said in my previous post.
Copy link to clipboard
Copied
By 'buttons' you mean checkboxes or radio buttons? But it doesn't really matter since 'required' is only useful when you submit the form not when you save it, you can't stop users to save the file, you can only set up alert so when they try to save, an alert can pop to notify them to fill in the fields if they are not filled (file will still be saved).