forms – Validation of custom Web forms

I have a web form with 195 different selection options, each with its own form key.

I want to create the form so that someone can only select 10 items, but the maximum number validation does not work and I try to understand how to make it work.

I can not group them under one key, I hope someone can help me out.