Required validation if another checkbox is ticked

I thought this would be easy until I've just tried to do it!

I have an input box which needs to be required. However, I also have a checkbox which, if it's ticked, the input box is no longer required as my SC script will provide the info instead. So, I need a validation to work like this:

If checkbox is NOT ticked, require this field

How can I do this?

<input id="MyField" dmx-bind:required="!chkbox.checked"></input>

this should work.

2 Likes

Perfect! I hadn’t even spotted the ‘Required’ dynamic attribute. I thought it was all done in validation rules.

Thanks @nshkrsh. Works perfectly.

Another bit of Wappler learned :slight_smile:

1 Like

What the required validation rule is doing is - adding the required attribute.

1 Like