For $n \in \mathbb{N}$, let $\mathcal{E}$=$\{e_n\}$ be an orthonormal sequence in $L^2[a,b]$. We need to show that $\{e_n\}$ is complete in $L^2[a,b]$ iff $\sum_{n=1}^{\infty} \mid \int_{a}^{x} e_n(t) dt \mid^2 = x-a$ for all $x \in [a,b]$.
I'm pretty lost on this one. Any help is appreciated.
Note that your identity actually means: $$\sum_n{\langle e_n,\,1_{[a,x]}\rangle^2}=\|1_{[a,x]}\|^2$$.
So $\Rightarrow$ is easy.
For $\Leftarrow$, prove that the identity implies that for all $x$, $1_{[a,x]}$ is in $H$, where $H \subset L^2([a,b])$ is the closure of the subspace generated by the $e_n$. Thus, every piecewise constant function is in $H$. Thus every piecewise continuous function is in $H$. Thus $H$ is the full $L^2$ space.