make multiple text boxes required if check box ticked

Apr 16, 2019

Copy link to clipboard

Copied

I am using this script

this.getField("cust Tel No").required = !event.target.isBoxChecked(0);

and it works but when i try and add extra text boxes it doesnt, where am i going wrong

this.getField("cust Tel No").required = !event.target.isBoxChecked(0); &&

this.getField("cust Tel Ar").required = !event.target.isBoxChecked(0);

TOPICS
Acrobat SDK and JavaScript

Views

190

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

make multiple text boxes required if check box ticked

Apr 16, 2019

Copy link to clipboard

Copied

I am using this script

this.getField("cust Tel No").required = !event.target.isBoxChecked(0);

and it works but when i try and add extra text boxes it doesnt, where am i going wrong

this.getField("cust Tel No").required = !event.target.isBoxChecked(0); &&

this.getField("cust Tel Ar").required = !event.target.isBoxChecked(0);

TOPICS
Acrobat SDK and JavaScript

Views

191

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
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

Drop the "&&" at the end of the first line.

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

Hi thanks,

I have 3 radio buttons, when i use the same script on the second radio button it doesn't work, any reason why and on the third radio button i don't want the text boxes to be required so how do i cancel the required?

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

Please describe how you want this to work, exactly.

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

I have 3 radio buttons and 4 text field that need to be completed if either the first or second radio button is checked. If the 3rd radio button is checked then i dont want these text boxes to be required. The radio buttons are choice 1, choice2 and choice 3, choice 3 being the button canceling the text boxes being required

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

What's the name of the radio-button group?

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

Also, what should happen if no radio button in the group is selected at all?

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

its called Group19, but i just figured out to change the 0 to 1 for the second button so now i just need to know how to cancel the text box being required

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

the radio group is required, there has to be one of the radios checked

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

I didn't follow what you meant, and the fact the field is required doesn't mean it will always have a selected value, which you have to take into consideration when writing the script.

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

I want to put at the end of the form a script that will ensure all required fields are completed before the form can be signed, however I am not there yet so am leaving that for another day

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

Well, you can use this code as the custom calculation script of a (hidden) text field to achieve it:

var v = this.getField("Group19").valueAsString;

var b = (v=="Choice 1" || v=="Choice 2");

this.getField("cust Tel No").required = b;

this.getField("cust Tel Ar").required = b; // etc.

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
Reply
Loading...
Apr 16, 2019 0
Apr 16, 2019

Copy link to clipboard

Copied

fantastic 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
Reply
Loading...
Apr 16, 2019 0