There is nothing inherently wrong with that, except you have to be specific about where $u$ lies. Using $ \sin{x} = \cos{(\pi/2-x)} $, we have
$$ \cos{(\pi/2-x)} = \cos{u}, $$
so we can choose $u=\pi/2-x$.
Going through with your substitution as-is requires some assumptions on the signs of the functions:
$$ \cos{x} \, dx = -\sin{u} \, du, $$
and
$$ \cos{x} = \sqrt{1-\sin^2{x}} = \sqrt{1-\cos^2{u}} = \sin{u}, $$
assuming that $\sin{u}>0$. Then the limits swap, and the above shows that actually $ dx = -du$, so you do find
$$ \int_0^{\pi/2} f(\sin{x}) \, dx = -\int_{\pi/2}^{0} f(\cos{u}) \, du = \int_0^{\pi/2} f(\cos{u}) \, du $$