Making Likert and Ink Sketch fields as required on public forms?

Hello,

Is there some Javascript code I can use to make Likert and Ink Sketch fields as required on public forms?

Thanks

Hello @chris.cundy,

You can make Likert Scale and Ink Sketch controls required by adding a custom validation:

fd.rendered(function(){
    fd.validators.push({
        name: 'LikertScale validator',
        error: 'Please, fill in Likert Scale',
        validate: function() {
            if (fd.control('LikertScale1').value.includes(null) || fd.control('LikertScale1').value.includes(undefined))
                return false;
    
            return true;
        }
    });

    fd.validators.push({
        name: 'InkSketch Validator',
        error: "Please leave a sign",
        validate: function(value) {
            if (fd.control('InkSketch1').value == null)
                return false;

            return true;
        }
    });
});

@mnikitina

Is there any way of this highlighting the parts of the form that arent filled out? Especially if there are sections with multiple Likert scales.

Thanks

@chris.cundy,

The form focuses on invalid fields or controls only if validation is added to a specific form element.

There is currently no way to add validation directly to Likert Scale and Ink Sketch controls, only with form validation. We are planning to add this functionality in the future, but there is no exact release date yet.

@mnikitina thanks!

Is there a list of other field types I can validate against in the form? Or is it mainly the Plumsail specific types? I'm gathering for SharePoint fields, I should just make these as required in the list for them to show up as invalid at the top of the form.

THanks

@chris.cundy,

For SharePoint fields, you can either make a field required in a column settings:
image

Or make a field required dynamically using the code:

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

For more complex validation, you can add form validators:

fd.validators.push({
    name: 'MyCustomValidator',
    error: "Age must be 18 or over in order to subscribe",
    validate: function(value) {
        if (fd.field('Age').value < 18
        && fd.field('PaymentModel').value == 'Subscription')
            return false;

        return true;
    }
});