mandatory on submit

Anubhav Srivas1
Tera Expert

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;
}

}

1 ACCEPTED SOLUTION

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:

AllenAndreas_0-1677196997725.png

AllenAndreas_1-1677197018266.png

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!

View solution in original post

6 REPLIES 6

Hi Divya,

 

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.

Faizeal Mohamed
Tera Guru

Hi,

 

When the conditions met set mandatory false for other fields and it should works

 

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);

 

g_form.setMandatory('only_public_facing_websites_should_be_used_with_axe_monitor_and_axe_report', false);

g_form.setMandatory('Only public facing websites should be used with Axe Monitor and Axe Report', false);
g_form.setMandatory('i_have_read_understood_the_above_points_and_agree_with_them ', false);

alert('Please select mandatory fields and submit');
return false;
}