
360 S.E.2d 345 (1987)
Wayne D. BLICK, et al.
v.
MARKS, STOKES AND HARRISON.
Record No. 840701.
Supreme Court of Virginia.
September 4, 1987.
*346 Gary R. Hershner, Richmond, for appellants.
W.F. Drewry Gallalee (William D. Bayliss, Browder, Russell, Morris and Butcher, P.C., Richmond, on brief), for appellee.
Present: All the Justices.
COMPTON, Justice.
This appeal of a judgment entered on a promissory note in favor of a law partnership against two clients has been limited to consideration of one issue. Code § 16.1-69.12(c) provides that substitute judges of courts not of record "shall not appear as counsel in any civil or criminal case arising out of the circumstances which were involved in any other case brought before them." The question presented is whether a violation of this statute renders void and unenforceable a contract between the law firm and the clients for services rendered.
In 1975, an ex parte order was entered in the Hopewell juvenile court placing the four children of Song Min U and his wife, appellant Myung Ja, in the temporary custody of the local department of social services. The order was requested by the department and was entered after a brief hearing by W. Park Lemmond, Jr., a substitute judge of the court and a partner in the law firm of appellee Marks, Stokes and Harrison.
This juvenile court action resulted from the father's desertion of the mother and children which, in turn, caused her to suffer emotional difficulties and to be hospitalized in 1975. The couple, natives of Korea, were divorced in 1977 and, after treatment for various conditions, the mother regained her health. She married appellant Wayne D. Blick in January 1979.
In September 1979, the social services department filed a petition in the juvenile court jointly against the father, who apparently had returned to Korea, and the mother as Myung Ja Blick, moving for termination of parental rights. Lemmond, as substitute judge, entered an ex parte order appointing a guardian ad litem when the petition was filed.
Later during that month, Mrs. Blick came to the offices of the Marks firm with the petition. Kevin M. McGowan, an associate in the firm, began representing her. At Mrs. Blick's request, McGowan filed a motion that she be awarded custody of her children. During the fall of that year, after a hearing, the judge of the juvenile court denied both motions. These rulings were appealed to the circuit court where the issues were heard on February 13, 1980.
Just prior to the hearing, because it was to be McGowan's "first trial of any major importance," he asked Lemmond, "a more experienced trial lawyer" under whom *347 McGowan "more or less" was working at the time, to assist him at the hearing. Lemmond had not been "actively" involved in the case to that point. Neither the clients nor the attorneys realized that Lemmond had participated in 1975 and 1979 as substitute judge in matters involving the U children.
During the hearing, in which Lemmond and McGowan represented the mother, the 1975 order was discovered among the court papers. The discovery stemmed from an inquiry about when the social services department first obtained custody of the children. The circuit judge then raised the question of an apparent conflict of interest and "the whole situation" was discussed in open court in the presence of Mrs. Blick, who had difficulty speaking and understanding the English language. Following this discussion, the circuit judge permitted the hearing to proceed, apparently believing that the attorneys had obtained the consent of Mrs. Blick for them to continue to represent her. Lemmond had no "active involvement" in the representation of Mrs. Blick after the hearing.
On February 14, 1980, the day following the hearing, the Blicks executed the promissory note in question. The instrument was in the amount of $2,635 payable to the Marks firm on demand. The note was taken by the firm as "security" for the then-existing debt of the Blicks for services rendered.
In July 1980, the circuit judge entered an order denying the department's petition for termination of parental rights and denying the mother's request for custody. She and the natural father, however, were granted reasonable visitation rights with the children.
In a letter dated April 9, 1981, Lemmond wrote to the Blicks that it had "been recently brought" to his attention that he had acted in the 1975 proceeding as a substitute judge. Accordingly, he wrote, his law firm and its individual attorneys would have to withdraw from representing them. Thereafter, the Blicks retained other counsel and refused to pay the Marks firm the balance for services it had rendered prior to withdrawal.
In May 1982, the law firm instituted the present litigation by bringing suit on the promissory note and seeking recovery of $2,521.50 due for services rendered. Defending, the Blicks asserted that the underlying contract of representation, upon which the note was based, was void because of Lemmond's violation of Code § 16.1-69.12(c). Hence, they alleged, the note lacked consideration and was invalid. In addition, the Blicks filed a counterclaim making numerous allegations against the firm and seeking recovery of compensatory and punitive damages. For example, they sought recovery of $2,475 paid to the Marks firm for services rendered prior to the execution of the note. Also, they charged that the representation was inadequate and involved a conflict of interest, causing them to expend additional funds to retain other counsel.
As the result of various pre-trial and trial rulings by the court below, the case was submitted to a jury on the claim and portions of the counterclaim. The trial judge instructed the jury that Lemmond's representation of the Blicks in 1980, after having entered the 1975 order as a substitute judge, created a conflict of interest between the firm and Mrs. Blick and, unless waived by her, rendered void the contract of employment.
During the trial there had been a conflict in the evidence on the issue of consent and waiver. McGowan testified that Mrs. Blick agreed, during the February 13, 1980 hearing, for the firm to continue to represent her after having the situation fully explained. She testified, however, that she was not informed about the conflict of interest and did not consent.
Thus, the trial court instructed the jurors that if they believed she was not informed about the conflict, they should deny the law firm's claim and award her $2,475 on the counterclaim. The court also told the jurors that if she, in fact, had been advised of the conflict and thereafter permitted the firm to continue to represent her, the verdict *348 should be in favor of the law firm on its claim and on the counterclaim.
The jury found for the Blicks. Subsequently, the trial court set the verdict aside, sustaining the law firm's contention that the contract of representation was not rendered void as the result of Lemmond's entry of the 1975 order when acting as a substitute judge. Accordingly, the court entered judgment on the note in the sum of $2,521.50 in favor of the Marks firm, and we awarded the Blicks this appeal from the February 1984 final order.
On appeal, the parties agree that the issue is whether the violation of the statute renders void the underlying contract of representation, thereby making the note unenforceable. We answer that query in the negative.
Generally, a contract based on an act forbidden by a statute is void and no action will lie to enforce the contract. Niemeyer v. Wright, 75 Va. 239, 243 (1881); Middleton v. Arnolds, 54 Va. (13 Gratt.) 489, 489-90 (1856). This general rule, however, is subject to exceptions, based on the intent of the legislature. "The courts should always look to the language of the statute, the subject matter, the wrong it seeks to prevent, and the purpose to be accomplished in its enactment; and if from these it is manifest that it was not intended to render the act in contravention of the statute void, the courts will so hold." Watters & Martin v. Homes Corp., 136 Va. 114, 127, 116 S.E. 366, 370 (1923).
The statute in its present form was enacted in 1980 by the General Assembly. Acts 1980, ch. 194. Dating to at least 1956, the statute and its predecessors have dealt with the limitations on the practice of law by judges who also are attorneys. See Acts 1973, ch. 546, p. 1258; Acts 1972, ch. 708, p. 968; Acts 1956, ch. 555, p. 858. The statute deals with the broad subject of professional conduct and with the ethical practices of attorneys and judges. Indeed, the Virginia Code of Professional Responsibility and the Canons of Judicial Conduct for the State of Virginia have provisions virtually identical to those of the statute. See Disciplinary Rule 9-101(A) ("A lawyer shall not accept private employment in a matter upon the merits of which he has acted in a judicial capacity") and Canon 8(D) ("A substitute judge shall not act as a lawyer in a proceeding in which he has served as a judge or in any other proceeding related thereto").
Examining the language and subject matter of the statute, though, we conclude that it does not deal only with professional responsibility and matters of ethics. Rather, the enactment has as its dominant purpose the aim to prevent prejudice to members of the public who are litigants and to avert unfairness to persons involved in litigation. For example, a lawyer who, in the representation of his client, is forced to take a position that is contrary to a decision which he rendered in a judicial capacity may not prosecute his client's cause with the greatest zeal thereby prejudicing the client's case. Or, a lawyer may have learned valuable information about a controversy while acting in his judicial capacity and, as a lawyer, be in a position to use that information, which he may not have acquired otherwise, to the disadvantage of the opposing party. These are the types of wrongs that this statute was designed to prevent.
Moreover, the statute does not mention contracts nor does it contain a penalty within its provisions. However, Code § 16.1-69.22, codified within the same article of the Code as the statute in question, does provide for removal of substitute judges under certain conditions. We are satisfied that the General Assembly intended that sanctions under that statute and under lawyer disciplinary procedures constitute adequate penalties for violation of § 16.1-69.12(c).
Therefore, we think it is manifest the legislature did not intend that contracts arising from a bare violation of the statute be void, unless, however, a litigant has been prejudiced by the violation.
And there has been no prejudice to the Blicks jointly or to Mrs. Blick individually or to her children. The law firm successfully *349 defended the effort by public authorities to terminate the residual parental rights of Mrs. Blick and her former husband. This effort involved representation at two levels of the judicial system. And while it is true the mother's motion for custody was denied on two occasions, she obtained visitation rights in the course of the litigation. From the medical evidence in the file, there was little chance that the mother could have been successful in obtaining custody of one or more of her children at the time of the hearings, but there was a distinct likelihood that she could have lost her parental rights. At the time, physicians reported that she had "psychiatric difficulties" and "emotional problems" caused, in part, by her attempts to adjust "to her present cultural environment." At the time, the mother was unable "to intellectually or emotionally cope with the stress and demands of developing children," according to a psychologist. Consequently, there having been no prejudice from the bare statutory violation, it follows that the contract of representation and the promissory note at issue were valid and enforceable.
There are numerous Virginia cases deciding similar issues and we will mention only a few. In Watters & Martin, supra, the "Blue Sky Laws" of Virginia were involved. Stock in a proposed corporation was sold without compliance with the enactment and a subscriber sought to avoid a stock subscription. This Court applied the exception to the general rule and enforced the subscription contract. The Court found that the purpose of the statute was to give the State Corporation Commission the power to regulate the sale of certain securities and to require the promoters to apply honestly the proceeds of the sale to prevent unfairness, not to make void and unenforceable contracts made in violation of the provisions of the statute.[*]
In Niemeyer, supra, fertilizer was sold in violation of statutes imposing specific labelling requirements. The Court permitted the seller to recover on the contracts of sale, holding it was not the intention of the legislature that contracts in contravention of the statutes should be void. 75 Va. at 248.
In Middleton, supra, a statute prohibited the conveyance and taking of pretensed titles. Apparently, there was a conveyance of land when the land was in the adverse possession of a stranger. This Court permitted an action to proceed that was brought to recover the purchase price. There, the purchasers defended on the ground that they and their vendors had violated the law because they knowingly sold and bought a pretensed title.
To be compared, not confused, with the foregoing line of cases is a different set of decisions, some of which are relied on by the Blicks. These cases stand for the proposition that "a contract made in violation of a statute enacted to protect the public against fraud, imposition, or to safeguard the public health, or morals, is illegal and unenforceable by the guilty party." Lasting Products Co. v. Genovese, 197 Va. 1, 8, 87 S.E.2d 811, 816 (1955). See, e.g., Cohen v. Mayflower Corp., 196 Va. 1153, 86 S.E.2d 860 (1955); Rohanna v. Vazzana, 196 Va. 549, 84 S.E.2d 440 (1954); Bowen Electric Co. v. Foley, 194 Va. 92, 72 S.E.2d 388 (1952); Colbert v. Ashland Construction Co., 176 Va. 500, 11 S.E.2d 612 (1940). This line of decisions is not controlling here because the statute at issue is not of the type construed in those cases, which involved an exercise of the police power of the State.
For these reasons, we conclude the trial court did not err in deciding that the note in question was valid and enforceable. Therefore, the judgment appealed from will be
Affirmed.
NOTES
[*]  Subsequent to the decision in Watters & Martin, the General Assembly amended the statute to provide expressly that contracts made in violation of the "Blue Sky Laws" would be voidable at the election of the purchaser of the security. Massie v. Dudley, 173 Va. 42, 54, 3 S.E.2d 176, 181 (1939).
