Costs shall not be recovered against the county elections official in any action under this chapter, unless it is alleged in the complaint, and established on the trial, that the county elections official knowingly and willfully violated his or her duty.