Limit Number of Characters

I am trying to limit the number of characters for fields that aren't text fields. I have choice fields that have other options that allow a user to input text and want to limit that part of the field to 40 characters. I am seeing how to do text fields but since this isn't a text field but a choice field with an other option I am not sure how to do this.

Any help would be appreciated.

Hello @Nazman1126,

You can add custom Form validator to the form to check the length of the input.

fd.validators.push({
        name: 'validate custom value input',
        error: "Error text",
        validate: function(value) {
            if (fd.field('ChoiceField').customValue.length > 40) {
                return false;
                    }
                return true;
    }
});

@mnikitina

This worked perfectly. I was able to tweak it as well for my multiline text fields. I thought a regular if statement would have worked, but now I know to use a validator.

Thank you very much for your assistance.

1 Like