title: Prevent form submission when validation fails (Angular Material)
body: <p>I just discovered Angular and Material design, and I really love all the features that come out of the box. I created a contact form with validation, which gives error messages when a field is required or is put in the incorrect format. The only thing that is missing is that when the user clicks the "submit" button, they can still send the form to the server. So the error messages don't really help.</p>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>&lt;md-content layout-padding=""&gt;
    &lt;form name="projectForm" action="/" method="post" novalidate&gt;
      &lt;div layout-gt-sm="row"&gt;
        &lt;md-input-container class="md-block" flex-gt-sm=""&gt;
          &lt;label&gt;Email&lt;/label&gt;
          &lt;input required="" type="email" name="emailAddress" ng-model="project.emailAddress" ng-pattern="/^.+@.+\..+$/"&gt;
          &lt;div ng-messages="projectForm.emailAddress.$error" role="alert"&gt;
            &lt;div ng-message-exp="['required', 'pattern']"&gt;
          Your email must be in correct format and look like an email address.
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/md-input-container&gt;
  &lt;/div&gt;
  &lt;md-input-container class="md-block"&gt;
    &lt;label&gt;Message&lt;/label&gt;
    &lt;textarea required="" name="content" md-maxlength="50" ng-model="project.content" rows="3" md-select-on-focus=""&gt;&lt;/textarea&gt;
    &lt;div ng-messages="projectForm.content.$error" role="alert"&gt;
      &lt;div ng-message="required"&gt;
        Your must enter a message.
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/md-input-container&gt;
  &lt;md-button type="submit" class="submit"&gt;Submit&lt;/md-button&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p><strong>JS</strong>:</p>
  
  <pre><code>angular
    .module('toast', ['ngMaterial', 'ngMessages'])
    .controller('formCtrl', function($scope) {
      $scope.project = {
        //scope stuff goes here
      };
    })
  </code></pre>
  
  <p>Here is the <a href="https://codepen.io/cmelone/pen/VayeQx" rel="nofollow">Codepen</a>.</p>