Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Require fields when submit button pressed

Community Beginner ,
Jun 09, 2023 Jun 09, 2023

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?

TOPICS
PDF forms
534
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2023 Jun 09, 2023

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);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 09, 2023 Jun 09, 2023

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2023 Jun 09, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines