Skip to main content
Participant
June 9, 2023
Question

Require fields when submit button pressed

  • June 9, 2023
  • 2 replies
  • 716 views

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?

This topic has been closed for replies.

2 replies

Legend
June 9, 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.

try67
Community Expert
Community Expert
June 9, 2023

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.

Nesa Nurani
Community Expert
Community Expert
June 9, 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);