Cognito-forms – Cognito Forms – Custom error based on a check box fill in field

cognito-forms

I have a list of items in check boxes. A user can mark as many as they want when filling in the form. However, I want an error if the user chooses "Pre-roll" and any other item. I'm able to figure out all but the "other" fill in box. How do I write that into the custom error?

enter image description here

I'm currently doing this for my custom error:

=(CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("300×250")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("728×90")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("320×50")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("300×100")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("Expanding video banner")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("1200×700")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("700×1200")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("480×320")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("Mobile floorboard/adhesion")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("500×800")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("800×500")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("600×60")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("700×700")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("Parallax")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("Pushdown")) or (CreativeSizes.Contains("Pre-roll") and CreativeSizes.Contains("Native"))

Is there anyway to trigger that custom error on the fill in box as well as all of the other options?

Best Answer

I'm a developer for Cognito Forms.

I believe the custom error calculation that you've shared can be simplified a bit, and will throw when "Pre-roll" and any other item (including the "Other" fill in box) is selected by using the following calculation:

=CreativeSizes.Contains("Pre-roll") and CreativeSizes.Count()>1

This is telling your field to throw the error when "Pre-roll" is selected, and when the count of items selected is greater than 1. This will include all of the other selections, including the "Other" fill in box.