Copy link to clipboard
Copied
I have three text boxes in a fillable PDF that I want to be required before the user presses the submit button. The submit button sends the form via email to someone.
I have checked the 'required' field for each of the text boxes but that's not stopping it from being submitted even if they are blank.
I'm assuming that this needs to be coded into the submit button. Any suggestions on how to do that?
Copy link to clipboard
Copied
Use this and change field names to your actual field names:
var f1 = this.getField("Field1").valueAsString;
var f2 = this.getField("Field2").valueAsString;
var f3 = this.getField("Field3").valueAsString;
if(f1&&f2&&f3){
//put your script for submitting here
}
else
app.alert("Please fill in required fields before submitting file.",3);
Copy link to clipboard
Copied
Also, bear in mind that it checks automatically for "required" only when a form is submitted. This can be done with a Submit form action or the submitForm JavaScript. Nothing else. People insinctively expect that it applies when their "submit" action takes place (such as a save, a mailDoc call etc.) but no.
Copy link to clipboard
Copied
It can be done using mailDoc, but will require validating the fields using a script. It won't happen by itself.
Search the forum for "validateRequireFields" for the code that does it.