- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 10:57 AM
Hi All,
I have requirement in catalog there are three checkbox and one multiline text .
No one field is not mandatory. but when we submit at one field check box or mutli line text will be add.
If we didn't add then submit false.
I have return client submit code. Please let us know if i want to modify anything.
Please find the attached documents for your reference.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 11:05 AM
Hi @Sirri ,
Plz find the updated code:
function onSubmit() {
// Get the values of the checkboxes and multiline text field
var checkbox1 = g_form.getValue('checkbox_field_1');
var checkbox2 = g_form.getValue('checkbox_field_2');
var checkbox3 = g_form.getValue('checkbox_field_3');
var multilineText = g_form.getValue('multiline_text_field');
// Check if at least one checkbox is selected or multiline text field is populated
if ((checkbox1 === 'true' || checkbox2 === 'true' || checkbox3 === 'true') || multilineText) {
// At least one field is populated, allow the form submission
return true;
} else {
// None of the fields are populated, prevent form submission and show an error message
alert('Please populate at least one checkbox or multiline text field before submitting the form.');
return
false;
}
Thanks,
Danish
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 11:05 AM
Hi @Sirri ,
function onSubmit() {
var checkbox1 = g_form.getValue('displayname');
var checkbox2 = g_form.getValue('mobilenumber');
var checkbox3 = g_form.getValue('checkbox');
var multilineText = g_form.getValue('additionalcomments');
if (!(checkbox1 || checkbox2 || checkbox3 || multilineText)) {
alert('Please fill out at least one field (checkbox or multiline text) before submitting.');
return false;
}
return true;
}
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 11:31 AM
Thank you, I have changed in your script return false and return true and the alert message.
but When I try to submit with one value that will not tacking as submission. Please let us know If still I want to modify.
Please find the attached document.