PDF form - Validate button coding when required status is dependent on radio button selection

Community Beginner ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Hi

I have created a form with a number of fields that are required. In order for the person completing the form to check they have completed everything they have to I created a validate button with the below coding so a message pops up if they haven't completed all the fields. 

if (

this.getField("Partnership status").value=="Off"||
this.getField("Question one").value=="Off"||
this.getField("Question two").value=="Off"||
this.getField("Question three").value=="Off"||
this.getField("Question four").value=="Off"||
this.getField("Question five").value=="Off"||
this.getField("Question six").value=="Off"||
this.getField("Declaration confirmation").value=="Off"
)
{app.alert("Please complete all required fields which are highlighted in red.")}

 

I have been asked however to make an additional field required "Date of event" depending on the answer given to "Partnership status" which is a group of radio buttons. To do this I've added to each radio button the following code with true or false depending on the action.

this.getField("Date of event").required = true;

 

I'm not sure though how to then add this in to the code for my validation button so that it can tell if this field is required or not and therefore needs completing or not. Thank you for any help with this.

 

 

TOPICS
How to, JavaScript, PDF forms

Views

217

Likes

Translate

Translate

Report

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

correct answers 1 Correct Answer

Adobe Community Professional , Mar 30, 2021 Mar 30, 2021
Not sure if I understand it right , but you can implement into code to check if field is empty and required.(this.getField("Date of event").value == "" && this.getField("Date of event").required == true);

Likes

Translate

Translate
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Not sure if I understand it right , but you can implement into code to check if field is empty and required.

(this.getField("Date of event").value == "" && this.getField("Date of event").required == true);

 

Likes

Translate

Translate

Report

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 Beginner ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Thanks, I've tried this but unfortunately the warning message isn't coming up for the validate button when the field has been made required but has been left blank.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Can you share  your file?

Likes

Translate

Translate

Report

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 Beginner ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

Hi

Yes, it will be a public form so I've attached a copy. The validation has also stopped working now except for the Full name, Date of birth, and telephone number fields so if there is a better way to do the script for this to incorporate the Date of event field being required/or not, and completed or not, I'm happy to change it. Thanks for your help.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Mar 30, 2021 Mar 30, 2021

Copy link to clipboard

Copied

My code will work but you have error in your script, change field name "Daytime telephone number" to

"Daytime phone number".

Likes

Translate

Translate

Report

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 Beginner ,
Mar 31, 2021 Mar 31, 2021

Copy link to clipboard

Copied

LATEST

That has all worked perfectly, thank you.

Likes

Translate

Translate

Report

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