Skip to main content
This topic has been closed for replies.
Correct answer brawal

Hi Kim,

You can apply the following script on the "Mouse Up" Action of the radio buttons.

Suppose you have 2 radio buttons A and B and you want to make the Text field (Text2) required when A is selected, you can add "Run a JavaScript" action on the

Mouse Up trigger of Button A:

if(event.target.value == "A") {

this.getField("Text2").required = true;

}

Mouse Up trigger of Button B:

if(event.target.value == "B") {

this.getField("Text2").required = false;

}

Please check this form for more.

Regards,

BR

1 reply

brawal
brawalCorrect answer
Participant
January 21, 2016

Hi Kim,

You can apply the following script on the "Mouse Up" Action of the radio buttons.

Suppose you have 2 radio buttons A and B and you want to make the Text field (Text2) required when A is selected, you can add "Run a JavaScript" action on the

Mouse Up trigger of Button A:

if(event.target.value == "A") {

this.getField("Text2").required = true;

}

Mouse Up trigger of Button B:

if(event.target.value == "B") {

this.getField("Text2").required = false;

}

Please check this form for more.

Regards,

BR

kimhuff1701
Known Participant
January 21, 2016

BR,

Thank you so much for the incredibly quick reply.  That worked perfectly for my radio buttons, but I have one checkbox that if it is checked, the field below is required.  It does work, but if the person changes their mind and un-checks it, the option (which is a radio button) still remains required after unchecking.

Thank you again for your time.

Kim

brawal
Participant
January 21, 2016

Hi Kim,

If I understood your query correctly, you have a check box, and then 2 radio buttons, if you check the check box, you should be able to make a choice between the 2 radio buttons, and when you select a particular radio button, a text field should become required. On un-checking the check box, the field should be optional, and the radio buttons should not have any option selected. (Please correct me if I got it wrong)

To do this, you can add this Java script on the "Mouse Up" trigger of the CheckBox:

if(event.target.value == "Yes") {

this.getField("Group1").value = "A";

this.getField("Text2").required = true;

}

else

{

this.getField("Group1").value = "";

this.getField("Text2").required = false;

}

Keep the previous script (on the radio buttons) untouched.

Please see this form.

BR