In an external assessment I want a submit button to be activated only if responded as 'Yes'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @omsirsat
I will suggest not to completely hide or deactivate the 'Submit' button (as this requires DOM manipulation which is not recommended as it often breaks during platform upgrades).
Instead, validate the form and prevent submission on the server side if the wrong answer is selected, accompanied by an explanatory error message
Option 1. Create an onChange Client Script:
- Variable Name: Select your acknowledgement Yes/No variable.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var ackQuestion = g_form.getValue('your_acknowledgement_variable_name');
if (ackQuestion == 'No') {
g_form.clearValue('your_acknowledgement_variable_name');
g_form.showFieldMsg('your_acknowledgement_variable_name', 'You must acknowledge the terms by selecting Yes to proceed.', 'error');
}
}
Option 2. Create an onSubmit Client Script:
- Set the UI Type to All and check the Isolate script box to false.
- Under the Type field, select onSubmit.
function onSubmit() {
var ackResponse = g_form.getValue('acknowledgement_question_var'); // Replace 'acknowledgement_question_var' with the actual Name
if (ackResponse == 'No') {
alert('You must answer "Yes" to the acknowledgement question in order to submit this assessment.');
return false;
}
}