title: Reopen login modal when login fails
body: <p>I made a login and register modal with Laravel Auth and materializecss modals (They work the same as Bootstrap modals). Everything works fine except one thing.</p>
  
  <p>There is a check when I submit my form for several thing: Do the email and password match? Does the email exist in the database etc. </p>
  
  <p>When one of the checks fails the user will not login and an error will be stored in the php array: $errors.</p>
  
  <p>The problem is that the modal closes when the form submits, which is fine when the login is good. But when the login fails and a error appears. Than the modal should be reopened and the error must be shown in the modal.</p>
  
  <p>I tried many things but I don't have much experience with JS and jQuery. I hope somebody can help and explain how it works?</p>
  
  <p>I solved the problem with this code:</p>
  
  <pre><code>    if ($('div#login-email').hasClass('has-error')) {
          $('#login-modal').modal('open');
      }
  
      if ($('div#login-password').hasClass('has-error')) {
          $('#login-modal').modal('open');
      }
  </code></pre>
  
  <p>Laravel adds a has-error class to the form-group where you did something wrong. So when there are no divs with the class: has-error, than everything is fine.</p>
  
  <p>When there is a div with the class has-error, than you failed at some point. So the modal should re-open.</p>