Skip to main content
Known Participant
August 30, 2024
Answered

can't get a yes no to validate correctly

  • August 30, 2024
  • 2 replies
  • 1350 views

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.

This topic has been closed for replies.
Correct answer Nesa Nurani

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).

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
August 30, 2024

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).

PDF Automation Station
Community Expert
Community Expert
August 30, 2024

What is your script?

vtrasikisAuthor
Known Participant
August 30, 2024

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);

}

 

vtrasikisAuthor
Known Participant
September 1, 2024

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).


Thanks, i tried it and it still did not work.. I put in: 

}

if(b9==undefined || b9.value.length=="Off")
{

error=true;

message+="You must choose USS affiliation before saving\r\n"

 

and when I clicked on save button, it checked everything else correctly but this one, what did I do wrong?