Do we really need $X$ to be compact Hausdorff? Let $R= C(X,\mathbb{R})$ be the ring of all continuous real-valued functions on a topological space $X$, where $\mathbb{R}$ is equipped with the standard Euclidean topology. Suppose $|X|>1$ and $X$ is connected and compact Hausdorff. Then the only idempotents in $R$ are the functions $0$ and $1$. Prove also that if $R$ is Von Neumann regular then $R$ is a field.
Proof:
We clearly have that $0^2=0$ and $1^2=1$. Now take $f \in R$ such that $f$ is idempotent. Then, for all $x \in X$, we have that $f^2(x)-f(x)=0$. This equation has only two solutions in $\mathbb{R}$, namely $f(x)=0$ or $f(x)=1$. Now define
\begin{align*}
A:=\lbrace x \in X \mid f(x)=0 \rbrace=f^{-1}(\lbrace 0 \rbrace) \\
B:= \lbrace x \in X \mid f(x)=1 \rbrace=f^{-1}(\lbrace 1 \rbrace)\end{align*}
Since $\mathbb{R}$ is equipped with the standard Euclidean topology, we know that all the singletons are closed subsets of $\mathbb{R}$. The continuity of $f$ implies that $A$ and $B$ are closed subsets of $X$. Furthermore, we have that $A \cap B = \emptyset$ and $A \cup B =X$. Assume that both $A$ and $B$ are non-empty (which is possible since $|X|>1$), then connectedness of $X$ gives us a contradiction. So we must have that $A=X$ and $B= \emptyset$ (and thus $f=0$), or $A= \emptyset$ and $B=X$ (and thus $f=1$).
Assume that $R$ is Von Neumann regular. Then, for every non-zero $f \in R$, we have that $(f)=(e)$, where $e \in R$ is idempotent. It follows that $(f)=R$ and thus $f$ is invertible. Hence, $R$ is a field.
Now, my question is the following: why did we need $X$ to be compact Hausdorff?
 A: I think you're right that the assumption $X$ is Hausdorff is unnecessary... all that matters is that the topology on $\mathbb R$ is enough to make points closed. 
As for compactness, I think you are also right that it is unnecessary.  Connectedness, the fact that $\mathbb R$ with the usual topology is $T_2$ (or even just $T_1$) and the continuity of the maps is all that's necessary to conclude there are only trivial idempotents.
And a VNR ring with trivial idempotents is a division ring, for exactly the reasons you gave.

Added:
Here's a screenshot of the solution from the companion book Exercises in classical ring theory

As you can see, the additional hypothesis that $X$ be compact and Hausdorff was used in the proof to appeal to the classification of maximal ideals of $C(X,\mathbb R)$.  The theorem in question says that the maximal ideals are exactly of the form $M_c=\{f\mid f(c)=0\}$.  
It looks like in this case, the author simply did not notice the elementary proof you have given above (that Hausdorff+connected+VNR implies field.)
Not sure exactly what the precise wording of the edition you're looking at is, but my guess is that it is aimed at using this same path to a solution.
A: It is indeed a standard topological fact that $X$ connected implies that $C(X)$ only has two-idempotents, and you've basically given the standard proof for it. It's part of exercise 1B in Gilman and Jerrison's classic "Rings of continuous functions". Compactness nor Hausdorffness are needed. Nor is $|X|>1$ needed: if $X$ is a singleton, then $C(X) \simeq \mathbb{R}$ and it's also true. Only connectedness matters.
