Quantcast
Channel: Gurock Software Support Forum
Viewing all articles
Browse latest Browse all 829

Conditional required field based on status

$
0
0

Hi,

I have a custom field called 'Devices' for test case results that I have made required through script (as opposed to the checkbox in when creating the new field). I would like to make it so that the field is only required when the status is NOT set to Pass or Blocked... so that when the user clicks Add Test Result in the dialog, it will only prevent the result from being added if the result is not Pass or Blocked. Here is what I have set up so far:

name: Conditional Required
description: Makes the Devices Field required if the case does not pass
author:
version: 1.0
includes:
excludes:

js:
$(document).ready(
    function() {
        $.subscribe('result_dialog.loaded', 'uiscript_conditional_required', function(o)
        {
            $('#custom_devices').prev().append(' <span class="required">*</span>');
        });

        $.subscribe('result_dialog.validate', 'uiscript_conditional_required', function(o)
        {
            if ($.trim(o.values.custom_devices) == '')
            {
                $('#addResultErrors').append('Field Devices is a required field.');
                $('#addResultErrors').show();
                o.event.stopPropagation();
                return;
            }
        });
    }
);

Thanks


Viewing all articles
Browse latest Browse all 829

Trending Articles