I think you can do this by using many methods, one of them is to add a simple
Attribute to selected cell like "isSelected='true'" by using jquery (like what you have do with CSS)
$(cell).attr("isSelected","true");
than filter by all TD that has isSelected=true if > 3, show your alert message