To vote in a primary election you must be a registered voter. In most states you must be registered in the party to vote in that party's primary. Some states permit "Decline to state" voters to request a ballot in a party's primary. California has a "top two" primary in which any voter can vote for any candidate, and the top two go on to the general election; they could both be Democrats.