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

Checkbox Toggle and Conditional Required Text Field

New Here ,
Jul 19, 2022 Jul 19, 2022

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
1.8K
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 ,
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;

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 ,
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;

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

Brilliant! Thanks!

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