Expand my Community achievements bar.

SOLVED

set a field as required based on radio button group

Avatar

Level 2

I not seen a solid answer if your can set field as required - in this case a date field based on the choice of a preceding radio button.

One post had that you could not do it with form calc, that it would have to be JS.

I am not the best at that.  The form will be submitted via post to a web server for data capture.

Any assistance would be appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Yes, you can change the "required" status of a field(s) using the validate.nullTest in either Formcalc or Javascript. You could use script like this in the exit event of the radio button:

if (this.rawValue == 1) then
    DateTimeField1.validate.nullTest = "error"
else
    DateTimeField1.validate.nullTest = "disabled"
endif

"error" sets the referenced field to required; whereas "disabled" changes it back to not required.

Good luck,

Niall

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

Yes, you can change the "required" status of a field(s) using the validate.nullTest in either Formcalc or Javascript. You could use script like this in the exit event of the radio button:

if (this.rawValue == 1) then
    DateTimeField1.validate.nullTest = "error"
else
    DateTimeField1.validate.nullTest = "disabled"
endif

"error" sets the referenced field to required; whereas "disabled" changes it back to not required.

Good luck,

Niall