stopping transition events

stopping transition events

How do you go about stopping page transitions? For example, on a form post, I want to do some validation, if its valid, just continue as normal, but if invalid, I do not want the page to transition. I thought the following would work, but not so much?

$('#form').submit(function(ev){

      // validation code...

      if (!valid) {
            return false;
      }

});