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

Checkbox Toggle and Conditional Required Text Field

New Here ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Hello,

I have a list of checkboxes (1-11) with Mouse Up script that unchecks Checkbox 12 if any of the checkboxes 1-11 are selected. If no checkboxes 1-11 are selected, then checkbox 12 is automatically checked. I have seen some refer to this as a toggle. See the following script:

var bChecked = (event.target.value == "Yes")

this.getField("Check Box12").value = bChecked?"Off":"Yes";

 

I have also set checkbox 12 as the default. So when a user opens the form, checkbox 12 will be checked unless they tick one of the boxes 1-11.

 

This works great, however, there is a text box that I would like to be required if checkbox 12 is checked. I believe the trouble I am having may be the result of the "toggle" function. Since there is no mouse function (up, down, enter, exit, on focus, or on blur) associated with the checking of box 12, I cannot seem to use script in the properties of the checkbox

 

Is there a custom calculation script that I can use for the text field to achieve my goal? Or any other options to make this possible? 

 

Thanks for any suggestions!

TOPICS
JavaScript

Views

930

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

Community Expert , Jul 19, 2022 Jul 19, 2022

Yes, as custom calculation of that text field use this:

event.target.required = this.getField("checkbox 12").value == "Off" ? false : true;

Votes

Translate

Translate
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

Yes, as custom calculation of that text field use this:

event.target.required = this.getField("checkbox 12").value == "Off" ? false : true;

Votes

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

Copy link to clipboard

Copied

LATEST

Brilliant! Thanks!

Votes

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