Multi Select Checklist hide other field if certain selection

Multi Select Checklist hide other field if certain selection

I have a multi select field that has about 10 check boxes representing products.

Any number of check boxes can be checked.

When certain boxes (eye wear products) are checked off, i need to show another field for lens size.

If non of the eye wear products are checked I do not want to show the lens size field. 

If an eye wear product and another product are checked I want to show the lens size field.


I can't seem to get this to work.  

It seems that i partially works but the field does not hide when it should and does not always show when it should depending on what is checked off and what order its checked in.


My code is as follows:


for each val in input.products
{
    if ((val.contains("glasses")  ||  val.contains("spectacles"))  ||  val.contains("binoculars"))
    {
        show lens_size;
    }
    else
    {
        hide lens_size;
    }
}


Thanks