"Intermediate Value Theorem" for curves
Solution 1:
EDIT 2: The question has been changed to ask not for a curve, but for a connected set. The below no longer applies but I am leaving it here in case others find it useful.
EDIT: The original version of the question was unclear; now that it has been clarified that one seeks a curve along which $f=0$, I believe the claim is false.
First, it is obvious that
1) The sub- and super-level sets where $f<0$ and $f>0$, respectively, are separated, and
2) The level set $f^{-1}(0)$ does not have to be a curve (consider for instance $$f(x,y) = \begin{cases}0, &\frac{1}{4} < y < \frac{3}{4}\\4y-3, &y\geq\frac{3}{4}\\4y-1, &y \leq \frac{1}{4}.\end{cases}$$
Now your question (if I'm interpreting it correctly) is whether the zero level set contains some continuous curve. I don't think this is necessarily the case. Consider for instance the set $S$ given by two copies of the topologist's sine curve: $$S = \left\{ \left( x,\frac{1}{2}+\frac{1}{2}\sin\frac{1}{2x-1}\right)\ \Big\vert\ x \neq \frac{1}{2}\right\} \cup \left\{\left(\frac{1}{2},y\right)\ \Big\vert\ 0 \leq y \leq 1\right\}.$$
$S$ is closed and so the distance function $d(x,y)$ of $(x,y)$ to $S$ is well-defined and continuous. Also define a sign function $\epsilon(x,y)$ to be 1 above and -1 below the sine curve, i.e.
$$\epsilon(x,y) = \begin{cases}\textrm{sign}\left(y-\frac{1}{2}-\frac{1}{2}\sin\frac{1}{2x-1}\right), &x\neq \frac{1}{2}\\0, & x = \frac{1}{2}\end{cases}$$ and set $f=\epsilon d$ to get a counterexample where $f^{-1}(0)$ is not path-connected.
(This $f$ does not exactly satisfy your boundary conditions at $y=\pm 1$, but this could be fixed by e.g. taking $f(x,y) = (\epsilon d)(x,[4y-1]/2)$ on $y\in (1/4,3/4)$ and extending appropriately.)
Solution 2:
Yes, there is a theorem from Topology (cf. `Topology,' by James R. Munkres) that says if $X$ and $Y$ are topological spaces, and if $f:X\to Y$ is continuous, and if $X$ is connected, then $f(X)$ is connected. Furthermore, if $A$ is a connected subset of the real number line, then $A$ must be an interval. To apply it to your case: The image of a path from $y=0$ to $y=1$ is a connected subset of the square. Then apply the previous results.
Solution 3:
Converting my comment to a loose idea of proof:
Assume it's not true - ie, the set of zeros of f is not connected between x=0 and x=1. Then there are 2 disjoint open sets, A and B, one containing the x=0 side, and the other one containing the x=1 side, which cover the entire set of zeros. Now let's prove that in the remaining piece of the square not covered by either A or B there is a connected component touching both y=0 and y=1. This would contain a path where f is non-zero (well, not exactly a path, but it would kind of break the notion of 'every connection between the two sides must equal zero somewhere'). Again, let's assume otherwise, so there are 2 disjoint open sets, C and D, one containing y=0, the other one containing y=1, which cover the remaining part of the square.
Now we prove that the boundaries of A and C, $\partial A$ and $\partial C$ intersect - with some hand-waving, the connected component of A containing the entire x=0 side has points both in the interior of C: (0, 0), and points in the interior of the complement of C: (0, 1), and since it's connected, it must also have points on the boundary of C, and the limit points of these will still be on the boundary of C, but will also be on the boundary of A. Now look at a single point $x \in \partial A \cap \partial C$. It is not inside A or C, since they are open, but it also cannot be in B or D. For example, if we assume $x \in B$ then there is an open neighborhood of x fully contained in B, and therefore disjoint from A, which is a contradiction with $x \in \partial A$. So x is not in $A \cup B \cup C \cup D$, which is a contradiction, we assumed that those 4 sets cover the square.