Whoever, being a candidate for any office, loans or gives, directly or indirectly, or offers or promises to loan, or give, any money, or other thing of value, to any elector, for the purpose of influencing or retaining the vote of such elector, or inducing such elector to work or labor for the election of such candidate, or to refrain from working or laboring for the election of any other candidate; or to any person to secure or to retain the influence or vote of such elector, in his behalf as such candidate, or to be used by such person in any way to influence the vote of any elector, or of electors generally, for himself or any candidate or ticket, shall be guilty of a misdemeanor, and, on conviction thereof, shall be fined not more than $1,000, or confined in the county jail for not more than one year, or both, in the discretion of the court.