You can do this by induction over the size of $X$ Or rather prove something stronger: If $f:Y\rightarrow Z$ is a function between sets of equal size, then $f$ is injective if and only if $f$ is surjective
Base: $|Y|=|Z|= 1$ (or possibly $0$ but that is completely trivial), then every function is both surjective and injective.
Induction assumption:
If $f:Y\rightarrow Z$ is a function on a sets $Y$ and $Z$ of size $n$ then $f$ is surjective if and only if $f$ is injective.
Induction step:
Assume $f:X\rightarrow W$ where $|X|=|W|=n+1$.
Assume $f$ is injective. Choose an element $a\in X$. The function $g:(X-\{a\})\rightarrow (W-\{f(a)\})$ such that $g(b)=f(b)$ for each $b\in X-\{a\}$ is then also an injective function between two sets of size $n$, and thus by induction assumption $g$ is surjective. However then each element in $W-\{f(a)\}$ is mapped to by something in $X-\{a\}$ and thus $f$ is surjective.
Assume $f$ is surjective. Choose an element $c\in W$ and assume that $f(a)=b$ for some $a\in X$. Again the function $g:(X-\{a\})\rightarrow (W-\{f(a)\})$ such that $g(b)=f(b)$ for each $b\in X-\{a\}$ is then also a surjective function between two sets of size $n$, thus the induction assumption implies that $g$ is injective. As $f(a)$ is not in the range of $g$, this implies that $f$ is injective.
This concludes the induction.
You might find the following question useful: http://math.stackexchange.com/questions/989043/rigorous-proof-that-surjectivity-implies-injectivity-for-finite-sets
– Luke Hamblin Nov 27 '15 at 12:08