If a person is affiliated with a party (Democrat or Republican) they can vote in a primary for the choices their respective parties offer.
If a person is unaffiliated (independent) they can declare an affiliation at the polling place and vote accordingly. If they wish to remain unaffiliated after the election, they can ask the board of election to send them a form they can fill out to state their wish to remain unaffiliated.
They can do that each time a primary occurs. That way, they can always vote in a primary but never be affiliated with a party long term.
If a person is affiliated with a party and wishes to change their affiliation, they must contact the board of election (the county clerk's office 908-527-4787) and complete a form 55 days prior to the primary election.
If by some chance a polling worker allows someone of a particular affiliation to vote for a candidate with whom they are not affiliated, that vote will be voided.
A PDF version of the Springfield sample ballot can be found here.