The CreatorCon Call for Content is officially open! Get started here.

Need to make sure one of two fields on a form is selected.

DeIvory Gordon
Tera Guru

Hello,

 

I have two fields on a form: 'Access to Remove' or 'Additional application(s) to be removed'.  I need to ensure that the user selects one of the fields and if at least one of the fields is not selected, the user should not be able to submit the for.  Initially, I made both fields mandatory, but the user would have to make a selection from both fields.  I am trying to configure the field so that the user has to select only one field, but if they select neither field, they should not be able to submit the form.  Please advise, thanks!

1 ACCEPTED SOLUTION

vignesh parthib
Tera Guru

Hi @DeIvory Gordon 

 

You can try On submit client script

  • Table: Your form’s table name (e.g., sc_req_item, incident, etc.)

  • Type: onSubmit

  • UI Type: All

function onSubmit() {
    var access = g_form.getValue('access_to_remove');
    var apps = g_form.getValue('additional_applications_to_be_removed');

    if (!access && !apps) {
        g_form.showFieldMsg('access_to_remove', 'Please fill at least one of the two fields.', 'error');
        return false; // Block form submission
    }

    return true; // Allow submission
}

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."

 

View solution in original post

1 REPLY 1

vignesh parthib
Tera Guru

Hi @DeIvory Gordon 

 

You can try On submit client script

  • Table: Your form’s table name (e.g., sc_req_item, incident, etc.)

  • Type: onSubmit

  • UI Type: All

function onSubmit() {
    var access = g_form.getValue('access_to_remove');
    var apps = g_form.getValue('additional_applications_to_be_removed');

    if (!access && !apps) {
        g_form.showFieldMsg('access_to_remove', 'Please fill at least one of the two fields.', 'error');
        return false; // Block form submission
    }

    return true; // Allow submission
}

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."