0

function onSubmit() {
     var condition = g_form.getValue('req_type);//Get the value of the catalog variable
     if (condition == 'add' || condition == 'modify') // Specify the variable choice value condition
{
        var countRequired = 1; // define the total no.of attachments to be attached before submit 
        if (window == null) {
            // portal
            if (this.document.getElementsByClassName('get-attachment').length != countRequired) {
                alert('You must add attachments before submitting this request.');
                return false;
            }
        } else {
            // native view
            var length = $j("li.attachment_list_items").find("span").length;
            if (length != countRequired) {
                alert('You must add attachments before submitting this request.');
                return false;
            }
        }
    }
}

Make attachment mandatory in service Portal via on submit catalog client script
Working Code Edited question March 4, 2024