In deciding any contest of a primary election, if the court can determine the candidate who has received a plurality of valid votes in the primary, it shall certify the name of that candidate to the State Board and the proper electoral board or boards. The candidate so certified shall be the party nominee and his name shall be printed on the official ballot for the election for which the primary was held. The name of no other person who was a candidate for the contested office in the primary shall be printed on the official ballots as a candidate for that office.
If the court is unable to determine which primary candidate received a plurality of valid votes or if the court decides that there has been no valid election, the party nominee shall be determined in accordance with the provisions of § 24.2-539.
Va. Code § 24.2-813