I believe it's only illegal to say, "only girls need apply". But, there are even exceptions to that. For example, if you're hiring an TSA agent who's job it is to pat down females, the person you hire would need to be a female as it's a requirement of the job.