
120 Cal.Rptr.2d 273 (2002)
98 Cal.App.4th 1077
YUBA CYPRESS HOUSING PARTNERS, LTD., Plaintiff,
v.
AREA DEVELOPERS, Defendant. James R. Smith, Plaintiff and Appellant,
v.
Area Developers, Defendant and Appellant.
No. C036661.
Court of Appeal, Third District.
May 29, 2002.
*275 Biegler Ortiz & Chan, Robert P. Biegler, Sacramento, Jesse S. Ortiz III and Paul Chan for Plaintiff and Appellant.
Michael R. Barrette, Yuba City, for Defendant and Appellant.
Certified for Partial Publication.[*]
*274 SCOTLAND, P.J.
Upon learning that Area Developers (defendant) had violated the Subdivided Lands Act (Bus. & Prof.Code, §§ 11000, et seq.), James R. Smith (plaintiff) sought to rescind his real estate contract with defendant and to recover moneys he had paid to defendant on the contract. After losing in the trial court, plaintiff prevailed on appeal. The judgment against plaintiff was reversed, and the case was remanded to the trial court with directions to calculate the reimbursement to which plaintiff was entitled and to enter judgment in his favor. (Yuba Cypress Housing Partners, Ltd. v. Area Developers (May 28, 1998, C024819) [nonpub. opn.].)
On remand, plaintiff moved for an award of attorney fees and costs pursuant to an attorney fee clause in the real estate contract. (Civ.Code, § 1717.) As the prevailing party, he sought to recover the fees *276 and costs he incurred at trial and on appeal.[1] Defendant opposed the request and moved to tax fees and costs. Among other things, defendant argued that (1) having obtained rescission of the contract on the ground that it violated the Subdivided Lands Act, plaintiff could not rely on the attorney fee clause because the entire contract was void due to its illegality, and (2) even if plaintiff is entitled to attorney fees via the contract, his claim for fees incurred on appeal was untimely.
The trial court ruled that the attorney fee clause of the contract was enforceable. However, relying on rule 870.2(c)(1) of the California Rules of Court, the court held plaintiffs request for attorney fees on appeal was untimely, and thus denied that request. The court also taxed a portion of the fees plaintiff incurred at trial. (Further rule references are to the California Rules of Court.)
Plaintiff appeals again. Defendant cross-appeals, claiming plaintiff is not entitled to recover any fees because the contract was illegal, therefore making its attorney fee clause unenforceable.
We shall reverse the judgment to the extent that it denies plaintiff recovery for the attorney fees he incurred on appeal. As we will explain in the published portions of this opinion, defendant is estopped from asserting that its violation of the Subdivided Land Act voided the entire contract, including the attorney fees clause; otherwise, defendant would benefit from its own wrong. And, since the initial judgment was reversed on appeal and the trial court was directed to enter a new judgment in favor of plaintiff, his request for attorney fees on appeal was governed not by rule 870.2(c)(1), but by rule 870.2(b)(1) because he incurred those fees before the rendition of judgment in the trial court on remand. Plaintiffs request was timely under rule 870.2(b)(1).
In the unpublished part of our opinion, we uphold the trial court's apportionment of attorney fees incurred at trial because plaintiffs attorneys also represented the partnership that did not prevail against defendant since it did not suffer any damages as a result of defendant's violation of the Subdivided Land Act.

DISCUSSION

I
Plaintiff disaffirmed his contract with defendant when he discovered that the contact was unlawful because defendant violated the Subdivided Lands Act. (Barrett v. Hammer Builders, Inc. (1961) 195 Cal.App.2d 305, 308-309, 16 Cal.Rptr. 49 [when a real estate contract is void for failure to comply with the Subdivided Lands Act, the purchaser "can either affirm the agreement and perform according to its terms or disaffirm the agreement and recover the sums he has paid less any allowable offsets" (fn.omitted)].)
*277 It follows, defendant argues, that the trial court erred in awarding plaintiff any fees based on the attorney fee clause of the contract that, in defendant's words, had been "voided due to illegality." We disagree.
Ordinarily, in an action on a contract providing for an award of attorney fees, Civil Code section 1717 entitles the prevailing party to attorney fees, even when the party prevails on the ground that the contract is inapplicable, invalid, unenforceable, or nonexistent, if the other party would have been entitled to attorney fees had it prevailed. (Hsu v. Abbara (1995) 9 Cal.4th 863, 870, 39 Cal.Rptr.2d 824, 891 P.2d 804.) This general rule "serves to effectuate the purpose underlying section 1717," which was enacted to establish mutuality of remedy where a contractual attorney fee clause makes recovery of fees available for only one party. (Ibid.)
However, as noted in Bovard v. American Horse Enterprises, Inc. (1988) 201 Cal.App.3d 832, 247 Cal.Rptr. 340 (hereafter Bovard) and Geffen v. Moss (1975) 53 Cal.App.3d 215, 125 Cal.Rptr. 687 (hereafter Geffen), "a different rule applies where a contract is held unenforceable because of illegality." (Bovard, supra, 201 Cal.App.3d at p. 843, 247 Cal. Rptr. 340; Geffen, supra, 53 Cal.App.3d at p. 227, 125 Cal.Rptr. 687.) "A party to a contract who successfully argues its illegality stands on different ground than a party who prevails in an action on a contract by convincing the court the contract is inapplicable, invalid, nonexistent or unenforceable for reasons other than illegality." (Bovard supra, 201 Cal.App.3d at p. 843, 247 Cal.Rptr. 340.) Because courts generally will not enforce an illegal contract, there is no need for a mutual right to attorney fees since neither party can enforce the agreement. (Id. at pp. 838, 843, 247 Cal.Rptr. 340.)
Bovard and Geffen are distinguishable from this case because they involved contracts that were entirely unenforceable by either party due to their illegal objects. (Bovard, supra, 201 Cal.App.3d at pp. 837, 839-841, 247 Cal.Rptr. 340 [contract to manufacture paraphernalia for use in facilitating the consumption of marijuana]; Geffen, supra, 53 Cal.App.3d at pp. 225-227, 125 Cal.Rptr. 687 [contract to purchase the "good will" of a law practice].)
Where the object of the contract is illegal, courts generally will not enforce it or lend assistance to a party who seeks to benefit from an illegal act. (Lewis & Queen v. N.M. Ball Sons (1957) 48 Cal.2d 141, 150, 308 P.2d 713.) "The reason for this refusal is not that the courts are unaware of possible injustice between the parties, and that the defendant may be left in possession of some benefit he should in good conscience turn over to the plaintiff, but that this consideration is outweighed by the importance of deterring illegal conduct. Knowing that they will receive no help from the courts and must trust completely to each other's good faith, the parties are less likely to enter an illegal arrangement in the first place." (Ibid.)
But in some cases "effective deterrence is best realized" by enforcing the plaintiffs claim or allowing some other remedy because "the forfeiture resulting from unenforceability [of the contract] is disproportionately harsh considering the nature of the illegality." (Lewis & Queen v. N.M. Ball Sons, supra, 48 Cal.2d at p. 151, 308 P.2d 713; 1 Witkin, Summary of Cal. Law (9th ed. 1987) Contracts, §§ 447-448, 450-451, pp. 399-402.)
"In each such case, how the aims of policy can best be achieved depends on the kind of illegality and the particular facts involved." (Leivis & Queen v. N.M. *278 Ball Sons, supra, 48 Cal.2d at p. 151, 308 P.2d 713.) Thus, for example, "when the Legislature enacts a statute forbidding certain conduct for the purpose of protecting one class of persons from the activities of another, a member of the protected class may maintain an action notwithstanding the fact that he has shared in the illegal transaction." (Id. at p. 153, 308 P.2d 713.) The protective purpose of the statute is realized by allowing the plaintiff, who is not in pari delicto, to enforce the contract or maintain his action against a defendant within the class primarily to be deterred. (Ibid. 308 P.2d 713; 1 Witkin, supra, Contracts, § 451, pp. 401-02.)
Here, the purpose of the Subdivided Lands Act is to protect members of the public who purchase lots or houses from developers. (Drake v. Martin (1994) 30 Cal.App.4th 984, 995, 36 Cal.Rptr.2d 704.) Hence, when a plaintiff purchased land under a contract that does not comply with the act, courts will allow the plaintiff to enforce the contract against the seller or to disaffirm the contract. (Barrett v. Hammer Builders, Inc., supra, 195 Cal. App.2d at pp. 308-309, 16 Cal.Rptr. 49.) In other words, the contract is voidable not void; since it does not have an illegal object, it is not one which neither party may enforce such that an attorney fee clause contained therein also is unenforceable.
Although plaintiff chose to void the contract, this does not preclude him from recovering attorney fees via the attorney fee clause in the contract. Rather, defendant, who violated the Subdivided Lands Act, is estopped from asserting the invalidity of the contract. (Barrett v. Hammer Builders, Inc., supra, 195 Cal.App.2d at p. 309, fn. 3, 16 Cal.Rptr. 49.) Otherwise, the court will have assisted defendant in profiting from its own wrong. To deny plaintiff the attorney fees to which he is entitled as a result of the contract would permit defendant to benefit from the illegality that it created, thus disserving the goal of deterring illegal conduct. (Cf. Homestead Supplies, Inc. v. Executive Life Ins. Co. (1978) 81 Cal.App.3d 978, 991, 147 Cal.Rptr. 22.)
Accordingly, the trial court properly concluded that the attorney fee clause of the contract was enforceable.

II
When a party prevails in litigation regarding a contract which contains an attorney fee clause, Civil Code section 1717 directs that, upon motion of the prevailing party, "[reasonable attorney's fees shall be fixed by the court, and shall be an element of the costs of suit." (Civ.Code, § 1717, subd. (a).)
After plaintiff prevailed on appeal and the case was remanded to the trial court to enter judgment in his favor, plaintiff moved for an award of attorney fees as costs. The trial court concluded the motion was untimely with respect to attorney fees plaintiff incurred on appeal. Thus, the court taxed the costs by deducting that amount.
We agree with plaintiff that the trial court erred.
Section 1034, subdivision (b) of the Code of Civil Procedure provides: "The Judicial Council shall establish by rule allowable costs on appeal and the procedure for claiming those costs." The applicable rules are California Rules of Court, rules 26 and 870.2. (Further references to rules are to the California Rules of Court.)
Rule 26(a) states in pertinent part: "(1) Except as provided in this rule, the prevailing party shall be entitled to costs on appeal.... [¶] ... [¶] (4) Unless otherwise ordered by the reviewing court, (i) an order or judgment regarding costs on appeal *279 neither includes attorney fees on appeal nor precludes any party from seeking attorney fees on appeal; and (ii) the issue of entitlement to attorney fees on appeal shall be determined by motion made in the trial court under rule 870.2."
Therefore, the procedure for claiming attorney fees as costs on appeal is set forth in rule 870.2, which begins as follows: "(a) Except as otherwise provided by statute, this rale applies in civil cases to claims for statutory attorney fees and claims for attorney fees provided for in a contract." The rule then continues, in convoluted fashion: "Subdivisions (b) and (c) apply when the court determines entitlement to the fees, the amount of the fees, or both, whether the court makes that determination because the statute or contract refers to `reasonable' fees, because it requires a determination of the prevailing party, or for other reasons."
The trial court apparently relied upon subdivision (c)(1) of rule 870.2 to find that plaintiffs motion for attorney fees was untimely to the extent it requested an award for fees incurred on appeal.
Subdivision (c)(1) of rule 870.2 states: "A notice of motion to claim attorney fees on appealother than the attorney fees on appeal claimed under subdivision (b)under a statute or contract requiring the court to determine entitlement to the fees, the amount of the fees, or both, shall be served and filed within the time for serving and filing the memorandum of costs under rule 26(d)." Accordingly, a party seeking an award of attorney fees covered by subdivision (c)(1) must, "within 40 days after the clerk of the reviewing court mails that party notice of the issuance of the remittitur, serve and file in the trial court a memorandum of costs . . .." (Rule 26(d).)
Although the notice of issuance of the remittitur in the first appeal was mailed to him on September 14, 1998, plaintiff did not file his motion for appellate attorney fees until June 25, 1999. Because the motion was filed after expiration of the 40-day time period specified in rule 870.2(c)(1), the trial court denied it as untimely.
The problem is the trial court overlooked that rule 870.2(c)(1) explicitly specifies it does not apply to "attorney fees on appeal claimed under subdivision (b)" of rule 870.2. (Italics added.) Subdivision (b) provides in pertinent part: "(1) A notice of motion to claim attorney fees for services up to and including the rendition of judgment in the trial courtincluding attorney fees on an appeal before the rendition of judgment in the trial court. shall be served and filed within the time for filing a notice of appeal under rules 2 and 3." (Italics added.)[2]
Some examples of situations where attorney fees are incurred on appeal before the rendition of judgment include, where a party seeks pretrial writ review of a ruling; where the appellate court reverses a judgment of dismissal following an order *280 sustaining a demurrer without leave to amend and the matter proceeds to trial and judgment; or where, as here, the appellate court reverses a judgment following trial and directs the entry of a new judgment.
In contrast, appellate attorney fees are incurred after rendition of judgment when the appellate court simply affirms the judgment without remanding the matter for further proceedings entailing the entry of a new judgment.
Although plaintiffs appellate attorney fees were incurred after rendition of the initial judgment in favor of defendants, that judgment was reversed and the case was remanded with directions for the trial court to enter a new judgment in favor of plaintiff. As a result, his appellate attorney fees now were incurred before the trial court's ultimate rendition of judgment in his favor. Thus, rule 870.2(b)(1) applies, and the applicable time limits are set forth in rules 2 and 3, which govern the time for filing a notice of appeal following the rendition of judgment.
At the time plaintiff filed his motion for attorney fees in 1999, rule 2 stated in pertinent part: "(a) Except as otherwise provided by Code of Civil Procedure section 870 or other statute or rule 3, a notice of appeal from a judgment shall be filed on or before the earliest of the following dates: (1) 60 days after the date of mailing by the clerk of the court of a document entitled `notice of entry' of judgment; (2) 60 days after the date of service of a document entitled `notice of entry' of judgment by any party upon the party filing the notice of appeal, or by the party filing the notice of appeal; or (3) 180 days after the date of entry of the judgment." Rule 3 describes the extensions of time that occur when various postjudgment motions are made.
In this case, the parties executed a stipulated judgment in favor of plaintiff in May 1999. Plaintiff then filed his motion for attorney fees on June 25, 1999. At a hearing held in July on the motion, the trial court told the parties that it expected them to file the judgment by the next hearing date. The judgment was entered on August 17, 1999, and notice of entry of judgment was mailed on August 26, 1999. After another hearing, the trial court ultimately decided the attorney fee motion on March 7, 2000.
Consequently, plaintiffs motion for attorney fees was filed prematurely, prior to the entry of judgment.
At the time plaintiff filed his motion for attorney fees, rule 2(c) stated: "A notice of appeal filed prior to entry of the judgment, but after its rendition, shall be valid and shall be deemed to have been filed immediately after entry. A notice of appeal filed prior to rendition of the judgment, but after the judge has announced his intended ruling, may, in the discretion of the reviewing court for good cause, be treated as filed immediately after entry of the judgment."
Because the timeframe set forth in rule 2 governs the filing of a motion for attorney fees as cost under rule 870.2(b)(1), a request for fees incurred before rendition of the judgment in the trial court may be timely even if it is filed prematurely prior to the entry of judgment. "Such a premature [motion] is to be liberally construed in favor of its sufficiency and treated as filed in accordance with rule 2(c), particularly where the opposing party is neither misled nor prejudiced by the premature filing." (Marcotte v. Municipal Court (1976) 64 Cal.App.3d 235, 239, 134 Cal.Rptr. 314.)
Here, defendant did not claim that the premature motion for attorney fees misled or prejudiced defendant; it simply argued *281 incorrectly that rule 870.2(c)(1) applied and the motion was untimely under that rule.
Hence, the trial court should have held that plaintiffs motion for attorney fees, filed a little over one month after the parties reached a stipulated judgment but almost two months prior to entry of the judgment, was timely under rule 870.2(b)(1).

III[**]

DISPOSITION
The judgment is reversed to the extent it denies plaintiff an award of attorney fees incurred on appeal. In all other respects, the judgment is affirmed. The matter is remanded to the trial court with directions to calculate the reasonable amount of attorney fees that plaintiff incurred on appeal and to which he is entitled. Defendant shall reimburse plaintiff for his costs on appeal. (Rule 26(a).)
We concur: DAVIS and CALLAHAN, JJ.
NOTES
[*]   Pursuant to California Rules of Court, rule 976.1, this opinion is certified for publication with the exception of Part III.
[1]  In the decision on appeal, this court ordered defendant to reimburse plaintiff for his costs on appeal. (Cal. Rules of Court, rule 26(a) [a party prevailing on appeal is entitled to costs on appeal "as an incident to the judgment on appeal," except "[i]n any case in which the interests of justice require it, the reviewing court may make any award or apportionment of costs it deems proper."].) Such costs are limited to the costs actually incurred for items specified in subdivision (c) of the rule, including the cost of preparation of the authorized record on appeal, the reasonable cost of printing or reproducing the prevailing party's brief, the filing fees, and the cost of service.
[2]  Prior to January 1, 1999, rule 870.2 provided in pertinent part: "(b) A notice of motion to claim attorney fees for services up to and including the rendition of judgment in the trial court shall be served and filed within the time for filing a notice of appeal under rules 2 and 3 .... [¶] (c) A notice of motion to claim attorney fees on appeal under a statute or contract requiring the court to determine entitlement to the fees, the amount of the fees, or both, shall be served and filed within the time for serving and filing the memorandum of costs under rule 26(d)."

Thus, under former rule 870.2, all appellate attorney fees were governed by subdivision (c) and nonappellate fees were governed by subdivision (b). The current version of rule 870.2, which was in effect at the time of plaintiff's attorney fee motion, differentiates between appellate attorney fees incurred before and after the rendition of judgment.
[**]   See footnote *, ante.
