Hello Team,
How can i disable the html input field until i checked the html checkox. My mockup is given blow, plase suggest any way to handle this.
Thankyou
disable input until check the checkbox
Answers approved by surveyjs Support
Hello Kartik,
From what I gather, you are using an HTML question and wish to disable inner HTML input text until a user checks an inner HTML checkbox. Unfortunately, the survey cannot track changes performed over inner HTML markup.
If you wish to conditionally show or hide survey elements, consider using Text and Checkbox/Boolean survey questions.
You can easily show and hide survey elements by specifying the visibleIf
expression.
For more information, refer to:
Please let me know if you have further questions.
then please tell me can i use validation in this like, when user checks the checkbox then validation message will be shown that please fill the input or if user fills the input but not checks the checkbox, then validation message displays that please check the check box.
if this can happen please tell me how can i fix this.
Thankyou
Hello Kartik,
You can enable the isRequired
option for your Checkbox question. Specify the enabledIf
and requiredIf
expressions for your Text question to enable it and make it required only when a user checks the checkbox.
Try this simple survey:
JSON{
"pages": [
{
"name": "page1",
"elements": [
{
"type": "checkbox",
"name": "question1",
"isRequired": true,
"choices": [
{
"value": "item1",
"text": "Check me"
}
]
},
{
"type": "text",
"name": "question2",
"enableIf": "{question1} = ['item1']",
"isRequired": true,
"requiredIf": "{question1} = ['item1']"
}
]
}
],
"showQuestionNumbers": "off"
}
Let me know if it works for you.