Plaintiff, Chester Rice, appeals from a judgment entered on a counterclaim in a court-tried case, awarding $9,000.00 plus interest to defendant, Leon James, for breach of an oral contract. We reverse.
Defendant is licensed by the City of St. Louis (City) as an electrical contractor. In order to obtain that license from the City, it was necessary for him to pass a test and be approved by an examining board. At the time of the events giving rise to this action, plaintiff was not licensed by the City as an electrical contractor, yet he was doing electrical contracting work at a job known as the Drew Towers project in the City.
On November 30, 1982, plaintiff approached defendant, stating the City was going to stop him from working on the project because he did not have a permit to do the work. Plaintiff could not get a permit because the City required a permit-tee to be a licensed electrical contractor. Plaintiff thereby asked defendant to obtain the permit in exchange for payment of $10,000.00. Defendant, however, was not the electrical contractor hired to do the *66work on the Drew Towers project, nor did his agreement with plaintiff require him to do any work. The agreement, which defendant characterized as a joint venture, provided that defendant, as a licensed contractor, was to obtain the permit for plaintiff, an unlicensed contractor, thereby enabling plaintiff to avoid being shut down. Defendant obtained the permit; plaintiff paid $1,000.00 under the agreement, but refused to pay the balance.
In an action brought by plaintiff, defendant filed a counterclaim seeking the balance claimed under the oral agreement with plaintiff. Following dismissal of all other claims, the counterclaim was court-tried. The trial court entered findings of fact and conclusions of law and rendered judgment in favor of defendant in the amount of $9,000.00 plus interest.
Plaintiff’s defense at trial was “illegality of the contract.” Plaintiffs contention was based upon City of St. Louis Ordinance (City Ordinance) Nos. 58536, adopted March 18, 1982, and 58032, (repealed), § 1504.1, which provided that no permit for electrical work shall be assigned or used to aid or abet any unlicensed person in the performance of electrical work.
The trial court found, inter alia, that plaintiff had failed to properly raise the issue of illegality and that, as matter of evidence, the ordinances were not before the court. Consequently, the trial court concluded that there was a valid and enforceable contract.
Conceptually, using the term “illegal contract” in reference to a bargain or agreement which either in its formation or performance is criminal, tortious or otherwise opposed to public policy is a non sequitur. With few exceptions, such an agreement does not result in a contract and therefore creates no change in legal relations. See Restatement (Second) of Contracts § 178 (1981) (referring to such agreements as “unenforceable”). The determining issue on appeal, therefore, is whether the agreement in this case became a contract which, upon breach, entitled defendant to recover for damages.
We first consider whether the issue of illegality was properly presented to the trial court. Plaintiff raised the issue of illegality in a motion to dismiss filed prior to trial. The record on appeal fails to indicate that plaintiff called up the motion for argument and the motion was never specifically ruled on by the court. By failing to proceed with the motion, plaintiff abandoned it. Vermillion v. Burlington Northern Railroad Company, 813 S.W.2d 947, 949 (Mo.App.1991).
Plaintiff did not raise illegality in his answer to defendant’s counterclaim. Rule 55.08 requires a party’s responsive pleading to set forth affirmatively illegality and any other matter constituting an avoidance or affirmative defense. The purpose of the rule is to give the opposing party notice of the issue so that, the party may then prepare to meet it. Schimmel Fur Company v. American Indemnity Company, 440 S.W.2d 932, 939 (Mo.1969).
An affirmative defense contemplates additional facts not included in the allegations necessary to support plaintiff’s case and avers that plaintiff’s theory of liability, even though sustained by the evidence, does not lead to recovery because the affirmative defense allows the defendant to avoid legal responsibility (citations omitted).
Parker v. Pine, 617 S.W.2d 536, 542 (Mo.App.1981). Notwithstanding the above, illegality, rather than avoiding a valid contract, may render the agreement void and unenforceable from its inception.
Any evidence which tends to show plaintiff's cause never had legal existence is admissible on a general denial even though the facts are affirmative, if and insofar as they are adduced only to negative the plaintiff’s cause of action and are not by way of confession and avoidance (citation omitted). Id.
In Detling v. Edelbrock, 671 S.W.2d 265 (Mo. banc 1984), the landlord filed a motion to dismiss tenants’ petition that sought, inter alia, specific performance of covenants of a rental agreement. Landlord contended that pursuant to provisions of the Property Maintenance Code and the *67Fire Prevention Code, the lease was illegal from its inception. Landlord did not, however, affirmatively plead the illegality. And unlike the present case, landlord’s motion to dismiss failed to raise the defense. Thus, as a matter of pleading, tenants were totally without notice of the defense raised. The Missouri Supreme Court found the defense of illegality waived, invoking the general rule requiring affirmative pleading in the answer. Id. at 271. Implicit in the court’s ruling was that the lease, without more, was valid on its face.
This distinction is apparent in Lucas v. Enkvetchakul, 812 S.W.2d 256, 263 (Mo.App.1991), where plaintiff sued on a promissory note. Defendant sought to avoid the obligation, but failed to affirmatively plead illegality of consideration of the underlying agreement. This court upheld the ruling below that defendant waived the defense, stating: “[t]he promissory note does not show on its face that it was made in contravention of the Missouri Uniform Security Act and so an affirmative plea was necessary” (citation omitted). Id. at 263.
Detling and hacas, accordingly, fall within the general rule that avoidance of a valid contract must be pleaded pursuant to Rule 55.08. Here, the situation is distinguishable from those found in Detling and Lucas. In this case, defendant, as moving party in an action for breach of contract, had the burden to plead and prove by his evidence a valid contract. Defendant thus was required to establish legal consideration,. which is an essential element of any contract. Douros Realty & Const. Co. v. Kelley Properties, Inc., 799 S.W.2d 179, 182 (Mo.App.1990). Certainly, plaintiff was entitled to attempt to negative defendant’s claim. The answer, which generally denied the existence of the contract, permitted the plaintiff to introduce evidence to show that there was no lawful consideration and therefore no contract existed. Parker, 617 S.W.2d at 542 (citing Stein v. Battenfeld Oil & Grease Co., 327 Mo. 804, 39 S.W.2d 345, 350 (1931)).
Finally, the issue of illegality or lack of lawful consideration was tried by the implied consent of the parties. Rule 55.33(b) provides “[w]hen issues not raised by the parties are tried by express or implied consent of the parties, they shall be treated in all respects as if they had been raised in the pleadings.” Failure to timely and specifically object to evidence beyond the scope of the pleadings constitutes implied consent for determination of the issues raised. Arnett v. Venters, 673 S.W.2d 67, 72 (Mo.App.1984). Here, none of the objections defendant made at trial were based upon the evidence of illegality being beyond the scope of the pleadings.
For the foregoing reasons, we find that the issue of illegality of the agreement was properly before the trial court.1
We next consider whether City Ordinance Nos. 58536 and 58032 were properly in evidence as bearing on the issue of illegality of consideration. City Ordinance No. 58536 provides in pertinent part:
1504.1 GENERAL:—No wiring system or electrical equipment shall be installed within or on any building or premises, nor shall any alterations or additions be made in any such existing installations, without first filing in the office of the Building Commissioner a written application for a permit to do the work contemplated ... No person shall begin such work unless and until he shall have received such permit_ No permit provided for in this section shall be assignable or transferable or used to aid or abet any unlicensed person in the performance of electrical work....
1507.3 REQUIREMENTS FOR BUSINESS PERMITS:—No person shall engage in any work set forth in Section 1504.0 [including 1504.1] of this Article unless and until, (1) he shall have filed with the Chief Electrical Engineer a written application to the Board of Public Service for a certificate to so engage; (2) such individual applicant or the officer or *68partner who has signed the application of a corporation, or whenever such officer or partner is not the person who will perform or supervise performance of the business, the responsible person shall have presented himself to the committee of examiners as hereinafter prescribed, and shall have passed the prescribed examinations successfully; (3) such applicant shall have been granted by The Board of Public Service a certificate of fitness to engage in the business specified in his application ... No person shall install or cause to have installed any of the work hereinbefore named unless such work shall be done by a person complying with the provisions of this Article.2
At trial, during defendant’s case, plaintiff sought to introduce the ordinances through stipulation of the parties. Defendant refused to stipulate and objected for lack of foundation. Plaintiff then asked the court to judicially notice the ordinances. Defendant again objected on the basis of lack of proper evidentiary foundation. While sustaining the evidentiary objection, the court did take judicial notice of the ordinances. No further objection was raised. However, in its findings of fact and conclusions of law, the trial court reversed its earlier ruling, citing the impropriety of taking judicial notice of a municipal ordinance.
In presenting his counterclaim, defendant testified that he was a licensed electrical contractor in the City; and while not making specific references to the ordinances, he described the procedures necessary to obtain both his electrician’s license and the permit plaintiff had sought. Defendant also identified and introduced into evidence as exhibits a copy of the electrical permit and the permit fee, both of which were presumably issued pursuant to the ordinances. Thus, defendant, in attempting to prove the contract, relied on the ordinances in question to prove his claim.
Here, the evidence establishes that defendant’s authority to obtain a permit from the City was derived from ordinances of the City. Indeed, the purpose of the agreement between plaintiff and defendant was to bypass the ordinances. By trying his case in reliance on certain provisions of the ordinances, he admitted the other provisions. See State ex rel. Bruno v. Johnson, 270 S.W.2d 99, 101 (Mo.App.1954). For defendant to take the position that the content of these ordinances was not before the trial court is an incongruity. An objection to the admissibility of evidence is waived where the same or similar evidence is elicited by the party objecting. Alvey v. Sears, Roebuck and Company, 360 S.W.2d 231, 234 (Mo.1962).
In addition, we consider the question of judicial notice. As a general rule a court may not take judicial notice of the existence or contents of ordinances. Consumer Contact Company v. State, Dept. of Revenue, 592 S.W.2d 782, 785 (Mo. banc 1980). Rather, the trial court may recognize an ordinance only if it is admitted into evidence or stipulated to by the parties. Queen of Diamonds, Inc. v. Quinn, 569 S.W.2d 317, 319 (Mo.App.1978).
In this case, although defendant objected on the basis of a lack of evidentia-ry foundation, no objection was raised to the trial court’s decision to take judicial notice of the ordinances. Failure to specifically object to the court taking judicial notice constitutes a waiver. See Murphy v. Graves, 294 S.W.2d 29, 34 (Mo.1956); Mound Rose Cornice & Sheet Metal Works, Inc. v. H. Kalicak Construction Co., 454 S.W.2d 603, 605 (Mo.App.1970).
We therefore hold that the trial court erred in ruling that the ordinances were not properly in evidence.3
*69Finally, based on the foregoing, we consider whether the trial court erred in finding the Rice/James agreement to be a valid and enforceable contract. Even if the ordinances were not in evidence, it is clear that the “joint venture” of the parties was designed to get something for plaintiff that he could not legally obtain for himself. The sole purpose of the agreement was to circumvent the ordinances of the City and permit an unauthorized person to do electrical work. An agreement providing for conduct prohibited by law is void based upon illegality of consideration. King v. Morehead, 495 S.W.2d 65, 77 (Mo.App.1973). Thus, defendant’s own evidence evinces a lack of lawful consideration necessary for a valid contract.
When this evidentiary deficiency is coupled with consideration of the ordinance which specifically prohibits this type of agreement, then the conclusion becomes irrefutable. The ordinance obviously has as its purpose the protection of the safety and health of the public. Any agreement or bargain that is predicated upon a violation of that ordinance is illegal and therefore unenforceable. Clouse v. Myers, 753 S.W.2d 316, 319 (Mo.App.1988). See Restatement (Second) of Contracts § 181 (1981).
We find that the consideration for the Rice/James agreement was illegal and thus defendant failed to prove an essential element of his action for breach of contract. The trial court therefore erred in entering judgment in favor of defendant.
The judgment of the trial court is reversed.
PUDLOWSKI, J., concurs. GRIMM, J., dissents in separate opinion.. Clearly the more prudent approach would he to plead illegality in the answer rather than risk running afoul of Rule 55.08.
. City Ordinance No. 58032 in pertinent part substantially tracts the language cited from No. 58536.
. Section 490.240, RSMo (1986), provides the manner in which a city or municipal ordinance may be proved at trial:
Printed copies of the ordinances ... purporting to be published by authority of such city ... and manuscript or printed copies of such ordinances ... certified under the hand of the officer having the same in lawful custody, with the seal of such city ... shall be received as evidence in all courts and places in this *69state, without further proof; and any printed pamphlet or volume, purporting to be published by authority of any such town or city, and to contain the ordinances ... of such town or city, shall be evidence, in all courts and places within this state, of such ordinances ...
See Queen of Diamonds, Inc. v. McLeod, 680 S.W.2d 289, 292 (Mo.App.1984). Compliance with this provision obviously is the preferable course in order to avoid any question as to the admissibility of an ordinance and to prevent the necessity of subsequent judicial proceedings on the issue.