Display error message and stop execution

Look at the article Adding Submit Messages to Your Form which will get you started.

You can also play with the Form Examples in your editor to see how they work.