Discrimination in employment
The starting point is: discrimination is legal unless there is a law that says it isn't.
So for example, when I advertise a plumbing position, I can discriminate on the basis of if a candidate is or is not a plumber and, further, I can discriminate on how good a plumber I think they are.
What I can't do, in the united-states is discriminate against someone on the basis of age if they are 40 or older. It is legal for me to discriminate against someone on age if they are younger than 40. Why? Because that's what the law says.
The full list of what constitutes illegal discrimination in employment is a person's race, color, religion, sex (including gender identity, sexual orientation, and pregnancy), national origin, age (40 or older), disability or genetic information. It is also illegal to retaliate against a person because he or she complained about discrimination, filed a charge of discrimination, or participated in an employment discrimination investigation or lawsuit.
Elections aren't employment
Voters are free to vote for the candidate of their choice based on whatever reason they want. If I want to decide that the only candidates I will vote for are female homosexuals between the ages of 27 and 62 with one leg and a pirate accent, then that's my right.