Opinion by
Spaulding, J.,This is an appeal from the judgment of the Court of Common Pleas of Lackawanna County affirming a fine and costs imposed upon the appellant in summary proceedings for violation of the Eansom Township zoning ordinance.
In January, 1965, the Township of Eansom, a second class township, duly adopted a zoning ordinance establishing various districts, including a Eesidential District and an Agricultural District. Under the ordinance, the keeping of livestock is not among the permitted uses in the Eesidential Districts. The appellant resides in the Township of Eansom and is the owner of a plot of land 100 feet by 150 feet upon which a barn is situated in the Eesidential District. At the time of the adoption of the zoning ordinance appellant used the barn to raise chickens, a nonconforming use. This use was subsequently discontinued and appellant began keeping a horse in the barn. Appellant was notified by the Township zoning board of adjustment that the maintenance of a horse in a residential district constituted a violation of the ordinance. Appellant then applied to the board of adjustment for a variance or permit to keep the horse on the premises. On September 10, 1965, the board notified appellant that his request had been denied. No appeal was taken from the decision of the board.
On November 19, 1965, a summons was issued by a justice of the peace alleging that appellant main*198tained a horse in a residential district in violation of the zoning ordinance. After a hearing, appellant was convicted of the violation by a justice of the peace and was ordered to pay a fine of $25 and costs of $9 in lieu of imprisonment.1 Appellant subsequently appealed the conviction by special allowance to the Court of Common Pleas of Lackawanna County, which dismissed the action and sustained the conviction. This appeal followed.
Appellant’s first contention is that The Second Class Township Code, §2004, Act of 1947, July 10, P. L. 1481, §47, as amended, 53 P.S. §67004, does not authorize enforcement of a zoning ordinance in summary proceedings by a fine imposed [in lieu of imprisonment] by a justice of the peace. Section 2004 provides : “The supervisors shall exercise the powers granted in section 2001 hereof [the power to zone], by ordinance, which shall provide for the enforcement of the regulations and restrictions established therein . . . by reasonable fines . . . .”
Appellant argues that since §2004, although authorizing reasonable fines, does not authorize collection of the fine through summary proceedings before a justice of the peace, a justice of the peace does not have jurisdiction to impose a fine in lieu of imprisonment for violation of the ordinance.
However, the procedure for collection of fines for violation of zoning ordinances is found elsewhere in The Second Class Township Code. Section 702, cl. XXV, of the Code, 53 P.S. §65725, grants to second class townships the specific power to adopt and enforce *199zoning ordinances. The procedure for enforcement of fines for violation of ordinances adopted pursuant to tlie specific powers of the township is provided in §702, cl. XLI, 53 P.S. §65741, which authorizes the collection of fines and penalties by suit or summary proceedings brought in the name of the township before any justice of the peace. This section further provides that upon judgment against any person by summary conviction, or proceedings by summons on default of the payment of the fine or penalty imposed, the defendant may be sentenced and committed to the township lockup for a period not exceeding five days, or to the county jail for a period not exceeding thirty days.2 Since the imposition by summary conviction of a fine in lieu of imprisonment for violation of .a zoning ordinance is authorized by §702, supra, we find that the penalty was properly imposed.
Appellant further argues that the conviction was improper because the township is without authority to prohibit the keeping of animals within the township and because the keeping of the horse on the premises is a continuation of a nonconforming use in existence at the time the ordinance was adopted.
*200The Second Class Township Code provides a complete procedure for consideration of the merits of a zoning case.3 The statutory remedy prescribed by the legislature is the exclusive remedy to be pursued by one aggrieved by a zoning ordinance and challenges to the constitutionality, validity, or application of a zoning ordinance may be decided only via this statutory procedure. Jacobs v. Fetzer, 381 Pa. 262, 112 A. 2d 356 (1955); Pittsburgh Outdoor Advertising Co. v. Clairton, 390 Pa. 1, 133 A. 2d 542 (1957); Philadelphia v. Budney, 396 Pa. 87, 151 A. 2d 780 (1959).
The requirement that the statutory remedy of appeal to the board of adjustment be used as the only avenue by which an aggrieved property owner may challenge the validity or effect of an ordinance has been held to prevent defendants in proceedings instituted to enforce a zoning ordinance from defending on the ground of the invalidity or improper application of the ordinance. In Philadelphia v. Budney, supra, defendants were not permitted to assert the defense that the use of their premises was an existing nonconforming use in an action in equity to enjoin the use. In Commonwealth v. DeBaldo, 169 Pa. Superior Ct. 363, 82 A. 2d 578 (1951), defendants were held to be barred from attacking the validity of a zoning ordinance on appeal from a summary conviction for violation of the ordinance.
Appellant failed to appeal from the decision of the board of adjustment denying his request for a variance. *201Instead of seeking to enforce Ms rights through the proper administrative procedures he continued to violate the ordinance, waiting for the township to bring enforcement proceedings in order to have his rights litigated. This violates the legislative directive in establishing an exclusive procedure for the litigation of zoning matters and the arguments raised cannot he considered here.
Judgment affirmed.
The Ransom Township zoning ordinance provides: “13.330. Penalties. Any person . . . violating any provisions of this Ordinance, shall, upon conviction, be punished by a fine not to exceed two hundred dollars ($200) for any offense, together with judgment or imprisonment not exceeding ninety days (90) if the amount of the said judgment is not paid.”
Although the issue was not raised by either party, the fact that §13.330 of the Ransom Township ordinance, providing for imprisonment not exceeding ninety days, permits imprisonment- for a period in excess of the maximum allowed in §702, does not invalidate the entire enforcement provision. In Commonwealth v. Schaeffer, 98 Pa. Superior Ct. 265 (1930), this court hold that a borough ordinance providing for a penalty in excess of the maximum amount authorized by The Borough Code was enforceable to the extent that it did not exceed the lawful amount. In so holding the court stated: “There seems to be no fundamental difference between treating an excessive fine as surplusage . . . and in changing a prison term. In both instances there is a reduction of the penalty in the ordinance to conform with the statute. If the action in the one ease is not the exercise of a legislative function, it ought not so to be regarded in the other.”
The Second Class Township Code, §2007, 53 P.S. §67007, provides: “(d) Appeals to the board of adjustment may be taken by any person or township official aggrieved or affected by any provision of the zoning ordinance or by any decision ....
“(i) Any person aggrieved by any decision of the board of adjustment . . . may . . . appeal to the court of common pleas of the county.”