Copy link to clipboard
Copied
I've searched through many of the posts/responses regarding how to lock certain form fields before submitting by email, copied many of the suggested scripts, but I'm still running into a problem with my Form.
The requirements are: (1) 4 specific fields are "required entry", (2) signature field is also required. At the bottom of my form are fields that are marked **For Office Use Only**, which I need to have available for entry afte the user has entered their data, clicked the button at the bottom of the form to lock the fields above and send it to the designated email address. My problem is that the script checks for the "name" field (which is a required entry), but doesn't check for the other required fields. And when I receive the completed document, the entire form is locked making it impossible to add the necessary validation (named Except1, Except2, Except3) at the bottom. Below is my current script, and I can't figure out what I'm doing wrong:
var aExcept = [ "Except1", "Except2"];
var ok = true;
var i = 0;
for (i = 0; i < this.numFields; i++){
try{
var f = this.getField(this.getNthFieldName(i));
if(f.required==true){
if(f.value==f.defaultValue && f.type != 'button' && f.type != 'signature'){
ok=false;app.alert('Missing Value: '+f.name);
}
}
}catch(ex){};
};
if(ok==true){
for (var i = 0; i < this.numFields; i++){
var f = this.getField(this.getNthFieldName(i));
f.readonly = true;
I would appreciate any help available in order to complete this project.
Copy link to clipboard
Copied
Hi,
My first thought would be how many fields are required?
If it is not that many then just cycle through them rather than all the fields, the reason for this is that it would simplify your code as you wouldn't need to check for "required" and for it not being a "button" or "signature".
Without the actual form it is hard to spot an error, as it could be something as simple as a field missing the "required" setting, or it could be some other combination that is causing the problem.
Are you able to attach the form to the original post? or share it in some other manner?
Regards
Malcolm
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Note that you are replying to the public forum, NOT via email to the person who replied.
Also, you can't attach files when replying via email. You have to do it through the browser.
Copy link to clipboard
Copied
In your script you doesn't use the variable aExcept.