Validate multiselect lookup field

Hi Plumsail

How can I validate multiselect lookup field?

The following code doesn't work:

//Multiselect field validation - [Wizard 3]
fd.field('LOOKUP Field1').validators.push({
    name: '',
    error: "Please select one item",
    validate: function(value) {
        if (!value) {
            
            return false;
        }
        return true;
    }
});

Dear @DryChips,
Are you sure you're using correct name for the field? It shouldn't contain spaces in it normally.

You have two options for this, either:

fd.field('LOOKUP').required = true;

Or:

fd.field('LOOKUP').validators.push({
    name: '',
    error: "Please select one item",
    validate: function(value) {
        if (value && value.length > 0) {
            return true;
        }
        return false;
    }
});
1 Like