title: jQuery remote validation on create vs update
body: <p>I have a Laravel 5.4 backend with validation rules all set up and working fine.</p>
  
  <p>I also implemented the <a href="https://jqueryvalidation.org" rel="nofollow noreferrer">jQuery Validation</a> plugin for client side validation for a better experience and used it successfully to test the remote validation. </p>
  
  <p>So for example checking for a unique email address when adding an entity:</p>
  
  <pre><code>$("#customerForm").validate({
  rules: {
      name: "required",
      email: {
          required: true,
          email: true,
          remote: {
              url: "/api/admin/customers/checkuniqueemail",
              type: "post",
              async: false,
              complete: function(data) {
                  if (data.responseText == "true") { //i.e. email is unique
                      // show some feedback
                  } 
              }
          }
      }
  },
  messages: {
      email: {
          remote: 'The email has already been taken.'
      }
  }
  </code></pre>
  
  <p>});</p>
  
  <p>This works perfectly.</p>
  
  <p>Questions:</p>
  
  <ol>
  <li><p>The above example works great when I'm adding a new entity. I would also like to validate on Updates but in that case it should exclude the current entity when checking for a unique email. This would mean I need to pass the primary key of the current entity along as well. Is my approach correct, and would the <a href="https://jqueryvalidation.org/remote-method/" rel="nofollow noreferrer">"data"</a> attribute be the recommended approach?</p></li>
  <li><p>Is there a way I can access the "action" attribute of the current form and send it along as a "data" variable.</p></li>
  </ol>
  
  <p>The reason I ask is that the within the Laravel "Edit" form, the entity id is part of the action url (e.g. /customers/edit/1234) and not really within a hidden field. So if I can get ahold of the "action" and send its value along, I can extract the ID and check for uniqueness except for that entity. I'm using <a href="https://laravel.com/docs/5.4/routing#route-model-binding" rel="nofollow noreferrer">Route Model binding</a> in case it's relevant</p>
  
  <p>Thanks!</p>