Any elector whose right to vote shall be challenged for any legal cause before an election officer, shall be required to swear or affirm that the matter of the challenge is untrue before his vote shall be received, and anyone who willfully swears or affirms falsely thereto, shall be guilty of perjury, and upon conviction thereof shall be imprisoned in the penitentiary for not less than one nor more than five years.