Skip to main content
AJ- monster
Inspiring
September 13, 2016
Question

Can I add in logic so if radio button "No" is selected, then make the "Comments" text field *Required?

  • September 13, 2016
  • 4 replies
  • 647 views

So I have a form with radio buttons Yes and No.  What I want to achieve is:

When Yes is selected the Comments text field is not required; but

When No is selected the Comments text field required, so as to force them to answer why they chose No.

Is this possible? 

I do not know code or Javascript so please explain as if I'm a 5 yr old.

Many thanks in advance

AJ

This topic has been closed for replies.

4 replies

try67
Community Expert
Community Expert
September 13, 2016

Yes, certainly. Set this JavaScript code to the Mouse Up event of both radio-buttons:

this.getField("Comments").readonly = (event.target.value=="No");

AJ- monster
Inspiring
September 14, 2016

Thanks.  I've never added Javascript before.  When I add this code in Mouse Up / Run Javascript it opens it gives me the options of cancel or Go To.  If I press GoTo it asks for a Line number.  I'm not sure what to do as the code isn't setting.

Like I said...I'm a notice with the code thing!

try67
Community Expert
Community Expert
September 14, 2016

There should also be an OK button... It should look like this: