Here is a question about two definitions. They are the following:

Definition 1. Let be a fixed algebraically closed field. If are two affine varieties, a morphism is a continuous map such that for every open set , and for every regular function , the function is regular.

Definition 2. A map between two affine varieties and is called a morphism if there exists polynomials such that for all .

These are two definitions from different textbooks: Hartshorne, Algebraic Geometry, and Mumford, Algebraic Geometry I. Are these definitions equivalent or a similar restatement of them equivalent? If so, how do you prove that they are equivalent? I believe that they are equivalent but I do not see how to prove this. Thanks for your help.