A voter may not vote for a person whose name is not on the ballot. Votes cast for a person whose name is not on the ballot may not be counted, but writing in a candidate's name does not invalidate the entire ballot.
AS 15.25.070
No write-in vote on primary ballot
Official source: Alaska State Legislature. Reproduced from public-domain Alaska statutes; confirm against the official source for the current text. Not legal advice.