Copy link to clipboard
Copied
Hi
I have the following javascript in a button before a form is ready for signature which is working, which I have found on various forums. However, I need to include 2 more items
1) to include checks on dropdown lists if they are visible and required, the default value of these dropdown lists are "SELECT ITEM",
and
2) if possible I would like to have an additional message displayed if a certain checkbox called divur1 is not ticked before displaying the main message which is included in my script below
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
} else {
// actions to complete when all required fields completed.
app.alert("Congratulations, all fields completed, Choose your name below and Digitally sign the form. DID THE CUSTOMER AGREE TO MARKETING EMAILS IF YES PLEASE CHECK THE BOX UNDER CONTACTS IS TICKED otherwise continue");
}
this.getField("Dropdown28").display = display.visible;
this.getField("Reset").display = display.hidden;
1. Change this line:
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
To:
if (f.display==display.visible && f.valueAsString==f.defaultValue) emptyFields.push(f.name);
2. Add this to your code:
if (this.getField("divur1").valueAsString=="Off") app.alert("Some error message.");
Copy link to clipboard
Copied
1. Change this line:
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
To:
if (f.display==display.visible && f.valueAsString==f.defaultValue) emptyFields.push(f.name);
2. Add this to your code:
if (this.getField("divur1").valueAsString=="Off") app.alert("Some error message.");
Copy link to clipboard
Copied
Hi
thanks it worked but now it is requiring all my radio buttons to be checked, how would I handle these as obviously they only require one choice and they are pre-checked on a standard
Copy link to clipboard
Copied
Not sure what you mean... If one of the radio-buttons is pre-selected, what is there to validate?
Copy link to clipboard
Copied
You are right I made the radio buttons as not required and resolved the issue