My last school, not in America, had dress codes for all its dances and the graduation, but they weren't just about modesty. Boys were forbidden black tie below senior year (to use equivalent American terminology), and for the sophomore dance jackets were discouraged, for the junior dance suits were permitted but not encouraged. For the senior dance black tie was encouraged, white tie was optional, and lounge suits acceptable, and for graduation cocktail wear was encouraged but higher formality was permitted.  For girls too the same classes of dress code were specified, and of course  needed more explanation, but the additional rules of not being more revealing or sexualised than would be permitted at other school events and not spending excessively were thought necessary, with the simple rule that if you weren't certain you should ask before buying anything. Most of the point of those events was to teach social graces in formal social events, and the dress codes formed part of that, although there weren't really enough of them for it to be effective.