Solved

How to create an optional repeating section with field validation

  • 5 August 2019
  • 2 replies
  • 75 views

Hi,

I have a requirement to allow a repeating section to be optional but still contain validation rules if one or more rows is being added.

 

I've seen that you can't have 0 minimum rows for a repeating section so I'm trying to find another way to solve this.

 

The repeating section has two fields, one is a dropdown where the user selects a value and the other is a text field, if they are entering a value both the dropdown and text field need values in them. Putting a checkbox above the repeating section "Requires repeating section" and then using rules to hide the repeating section the validation still triggers when the repeating section is hidden.

 

I know the Validation Required property on the two fields supports the value Yes/No or Expression, is it possible to write an expression that checks the value of that checkbox indicating that the repeating section isn't required to mean the fields are no longer required? I haven't found an example of an expression anywhere in the documentation or these forums so I'm not sure what it should look like and nothing I've tried seems to work.

icon

Best answer by SimonMuntz 6 August 2019, 07:22

View original

2 replies

Userlevel 6
Badge +22

Hi,


 


You can add to your rule to check if the checkbox is checked before validating the controls.


 


Example of one of the validation rules which checks the the checkbox before applying the rule.


and( CheckBox == true, isNullOrEmpty(Single Lines Of Text Control))

Please see the attached form example.


 

Thanks, for some reason my form seemed to have corrupted that text field, your sample proved I was on the right track, I removed the control and added it again and it suddenly worked. It didn't seem to be accepting that I'd turned off the control validation and was wanting a rule to do the validation of that control.

Reply