Use Forms and validation for this kind of stuff.
What is the expected behavior if the check fails?