Actually it is illegal in California except for very special circumstances.

1) If an owner is selling the goodwill in their business. (Business & Professions Code Section 16601).
2) When there is a dissolution or disassociation of a partnership. (Business & Professions Code Section 16602).
3) Where there is a dissolution of a limited liability company. (Business & Professions Code Section 16602.5).

http://caselaw.lp.findlaw.com/cacode...600-16607.html