Если я оставлю при проверке только условие, оно работает нормально, но когда я добавляю более одного условия, оно пытается проверить все три независимо от условия выражения.
Ниже JSON можно использовать в Survey JS codepen или codeandbox:
Код: Выделить всё
{
"pages": [
{
"name": "page1",
"elements": [
{
"type": "radiogroup",
"name": "Gym",
"title": "Do you go to GYM",
"isRequired": true,
"choices": [ "Yes", "No" ]
},
{
"type": "radiogroup",
"name": "GymDur",
"visibleIf": "{Gym} = 'Yes'",
"title": "How long have you been going to GYM",
"resetValueIf": "{Gym} = 'No'",
"isRequired": true,
"choices": [ "Days", "Months", "Years" ]
},
{
"name": "GymDura",
"type": "text",
"title": "Enter Duration",
"inputType": "number",
validators: [
{
type: "regex",
regex: "^(?:[0-9]|[1-2][0-9])$",
text: "Value should be less than 29.99",
expression: "{GymDur} = 'Days'",
},
{
type: "regex",
regex: "^(?:[0-9]|1[01])$",
text: "Value should be less than 11.99",
expression: "{GymDur} ='Months'",
},
{
type: "regex",
regex: "^(?:d{1,2})(?:.d{1,2})?$",
text: "Value should be less than 99.99",
expression: "{GymDur} ='Years'",
},
],
},
],
}
],
}

Подробнее здесь: https://stackoverflow.com/questions/798 ... expression