Assume you have a radio button field named Field1 in your form with values "Yes"/ "No" and you want Field2 to be required only if the value ofField1 is "Yes". To achieve the given scenario, add the given script to Form Actions -> On add -> validate section of the Script tab.
if ((input.field1 == "Yes") && (input.field2 == null))
{
alert "Enter a value for field2";
cancel submit;
}
The above script checks if there is any data input into field2 when field1 value is "Yes". If there is no data, submit is canceled and an alert message is displayed.