The US Supreme Court invalidated a law like this, that was on the books in Georgia. See Chandler v Miller, 520 US 305 (1997).