- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 10:33 AM
Hello Experts,
I'm getting issue on a onsubmit client script, i want some options based on condition to be mandatory and it is doing it's job but even after selecting all the fields it is still giving an alerts and doesn't allow to submit the request through SP.
Here's the script, Please help:
function onSubmit(){
if (g_form.getValue('igt')=='true'){
g_form.setMandatory('igt_stores_the_content_of_your_dom_including_data_scenario_results_on_saas_for_analysis_so_only_synt', true);
g_form.setMandatory('the_ui_of_your_application_should_be_pci_dss_compliant', true);
g_form.setMandatory('igt_access_will_be_provided_for_3_months_an_extension_request_has_to_be_made_to_continue_using_for_a', true);
g_form.setMandatory('igt_stores_the_content_of_your_dom_including_data_scenario_results_on_saas_for_analysis_so_only_synt', true);
g_form.setMandatory('i_have_read_understood_the_above_points_and_agree_with_them', true);
alert('Please select mandatory fields and submit');
return false;
}
else if (g_form.getValue('axe_monitor')=='true'){
g_form.setMandatory('only_public_facing_websites_should_be_used_with_axe_monitor_and_axe_report', true);
g_form.setMandatory('I have read & understood the above points and agree with them', true);
alert('Please select mandatory fields and submit');
return false;
}
else if (g_form.getValue('axe_report')=='true'){
g_form.setMandatory('Only public facing websites should be used with Axe Monitor and Axe Report', true);
g_form.setMandatory('i_have_read_understood_the_above_points_and_agree_with_them ', true);
alert('Please select mandatory fields and submit');
return false;
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 04:05 PM
Hi,
In the future, it's always a good idea to include as much information as you can, such as the field types, because we've now spent time giving suggestions for things that you have already thought through yourself or have reasons for using the script that you did. Giving more information helps us help you and also prevents us wasting both your time and ours. Anyways, you can still avoid using a script and use a UI Policy with checkboxes to make certain specific ones mandatory by using containers to wrap around them and "break" them from being in a group, like so:
Otherwise if you still must use your script, then you'd need to check your field names and values to ensure everything is properly setup as it shouldn't execute the alert statements if the if statement isn't true.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 10:39 AM
Hi,
This looks like it'd be better in a UI Policy, where you set the condition that if 'x' field is 'y' value, then a,b,c fields are mandatory. Evaluating things in an onSubmit client script and then making fields mandatory isn't the best user experience and I wouldn't recommend it. Just my 2 cents.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 03:32 PM
Hi Allen,
Since these are checkboxes i'm forced to use script. By using UI policy only one option is set to mandatory and others are not.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 04:05 PM
Hi,
In the future, it's always a good idea to include as much information as you can, such as the field types, because we've now spent time giving suggestions for things that you have already thought through yourself or have reasons for using the script that you did. Giving more information helps us help you and also prevents us wasting both your time and ours. Anyways, you can still avoid using a script and use a UI Policy with checkboxes to make certain specific ones mandatory by using containers to wrap around them and "break" them from being in a group, like so:
Otherwise if you still must use your script, then you'd need to check your field names and values to ensure everything is properly setup as it shouldn't execute the alert statements if the if statement isn't true.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2023 10:47 AM
Hi,
Use Ui Policy to do it better or make sure conditions given are correct