IIRC they basically try to chase up your eye doctor for you, and if your eye doctor doesn't respond within a certain timeframe, they have a greenlight to proceed with the sale according to a California law that was passed maybe 10 years ago. It's probably different in different states - maybe in some states you can literally just type in whatever you want.
Zenni does let you buy "whatever you want".
I'm not aware of anything on the federal level that requires a patient have a valid prescription for eyeglasses. (I've looked, but I've not found any such requirement.)
The restrictions appear to be on the state level. Some states prohibit dispensing prescription glasses without a prescription. Other states appear to only regulate what a prescription must contain, and how long it lasts, with no apparent laws around dispensing. (For example South Dakota explicitly does not regulate opticians, so unless there is some federal law I have missed, they can produce and dispense any type of glasses to anyone who asks, but cannot do so for contacts due to the FTC contacts rules.)