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

Submit Button Highlights Filled In Required Fields

Community Beginner ,
Dec 31, 2020 Dec 31, 2020

I have a form with several required fields. When the submit button is clicked and ONE of the required fields is blank an error message is displayed "At least one required field was empty. Please fill in the required fields (highlighted) before continuing". The issue is that ALL of the required fields are highlighted even if they are not blank. Is there a way to highlight just the field(s) that are blank? 

TOPICS
PDF forms
12.5K
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 03, 2021 Jan 03, 2021

You can try with a mouse-up event action script like :

 

// loop through all fields in the document

for ( var i=0; i < this.numFields; i++) {

//get the field names and declare variables
var fname = this.getNthFieldName(i);
var f = this.getField(fname);


/*establish a condition, if the field is not a button type object, and fields are marked as required but the value is empty */

if (f.type != "button" &&  f.required == true) {

if (f.value == "") {


//trigger an alert for the user to identify which fields are empty

app.alert({

cMsg: "Please complete required field(s) before submitting this form: " + f.name,

cTitle: "Required Fields Check "});

}
} 

 

This is just a very small example of this type of script. You can add more to it.

 

 

View solution in original post

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 ,
Nov 12, 2023 Nov 12, 2023
LATEST

HI @Yvonne33372078ja52 ,

 

Would you mind sharing the script that you're using? Or better yet, a copy of your PDF (if you can).

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