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

Hide Submit PDF Button based on combination of filled in fields

New Here ,
Jul 05, 2022 Jul 05, 2022

Hey there ... I have a fillable PDF form that needs to be submitted using a Submit PDF button based on certain logic provided by my client:

 

There are 3 main fields in play

1) address field

2) phone field

3) email field

 

Client wants it so these scenarios happen at the same time:

#1 - address field filled in YES, phone and email NOT FILLED - result:  NO submit button

#2 - phone field filled in YES, address and email NOT FILLED - result:  NO submit button

#3 - email field filled in YES, address and phone NOT FILLED - result:  NO submit button

#4 - address AND phone fields FILLED YES, email field not filled - result:  YES submit button

#5 - address AND email fields FILLED YES, phone field not filled - result:  YES submit button

 

I have the following code written:

 

this.getField("Submit-Form").display = display.hidden;

var showSubmitForm1 = true;
var checkLength1a = this.getField("Defendant-Address").value.length;
var checkLength1b = this.getField("Defendant-Phone-Number").value.length;
var checkLength1c = this.getField("Defendant-Email-Address").value.length;

if(checkLength1a == 0) {
showSubmitForm1 = false;
}
if(checkLength1b == 0) {
showSubmitForm1 = false;
}
if(checkLength1c == 0) {
showSubmitForm1 = false;
}

 

if(showSubmitForm1) {
this.getField("Submit-Form").display = display.visible;
}
else {
this.getField("Submit-Form").display = display.hidden;
}

 

*****************************

I think I may be missing the && statement somewhere to connect address + phone OR address + email fields but not sure.

 

Any help is most appreciated.

Have a great day.

 

Woody House

Online Graphics

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF forms
426
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 ,
Jul 05, 2022 Jul 05, 2022

Try use this part of script:

if(checkLength1a == 0 && checkLength1b == 0 && checkLength1c == 0) {
showSubmitForm1 = false;
}
else if(checkLength1a != 0 && checkLength1b == 0 && checkLength1c == 0) {
showSubmitForm1 = false;
}
else if(checkLength1a == 0 && checkLength1b != 0 && checkLength1c == 0) {
showSubmitForm1 = false;
}
else if(checkLength1a == 0 && checkLength1b == 0 && checkLength1c != 0) {
showSubmitForm1 = false;
}

What you want to happen if phone and email are filled?

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
New Here ,
Jul 05, 2022 Jul 05, 2022
LATEST

This is really good but slightly off ...

PHONE and EMAIL are FILLED - Address is not filled = result:  NO Submit Button

 

I got it working using your logic but now, if ONLY the ADDRESS field is FILLED = result:  YES Submit Button which cannot happen ...

 

ONLY 3 instances where Submit = YES are:

1) ADDRESS + PHONE + EMAIL are filled

2) ADDRESS + PHONE are filled ( email blank )

3) ADDRESS + EMAIL are filled ( phone blank )

 

Thanks ... you rock this stuff!

Woody

 

 

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