That would be impossible to do; however, many states have so called Romeo laws, which acknowledge that there is a big difference between a 17 year old having sexual relations and with someone who is 18 vs 40. These laws generally put a 2 year window on age that overrides statutory rape laws.
There is a lot of difference in maturity between kids 14-18. Some 18 year olds look like children and some 14 year olds look like adults (especially with makeup).
IMHO, any adult that is over 20 shouldn't be dating someone in HS, although the level of maturity is overlapping.
Some of the urban high schools have done that around here. A few of them have totally separate academies for the 9th graders, in different buildings. Two of them that have their 9th graders keep the boys and girls segregated, and the directions are if an upperclass boy even looked inside those grade 9 girls' classrooms, call security.
The most impressive thing is that when rules are strict, no exceptions, no favoritism, the kids, both young girls and older guys, accept them with grace and humor (I'm not being sarcastic)