title: Email Vaildation Magento 2.2
body: <pre><code> jQuery(function() {
          var emailAddress = jQuery('#email_address');
          emailAddress.on("change", function () {
             var mail=emailAddress.val();
  
              jQuery.ajax({
                  type: "POST",
                  url: "/customer/email/",
                  dataType: "json",
                  data: {email: mail},
                  success: function (exist) {
                      if (exist == 1) {
                         alert("exist");
                      } else if (exist == 0) {
                          alert("exist");
                      }
                  },
                  error: function (jqXHR, textStatus, errorThrown) {
  
                          alert("Error " + jqXHR.status + " " + jqXHR.statusText);
  
  
                  }
              });
          });
      });
  </code></pre>
  
  <p>Controller email.php</p>
  
  <pre><code> public function execute()
  {
      $customerEmail=$this-&gt;getRequest()-&gt;getParam('email');
      $objectManager=\Magento\Framework\App\ObjectManager::getInstance();
      $CustomerModel = $objectManager-&gt;create('Magento\Customer\Model\Customer');
      $CustomerModel-&gt;setWebsiteId(1);
  
      $CustomerModel-&gt;loadByEmail($customerEmail);
      $userId = $CustomerModel-&gt;getId();
      if ($userId) {
          return 1;
      } else {
          return 0;
      }
  </code></pre>
  
  <p>I want to check email before clicking create an account button using Ajax, i am not getting to do that, please help me out to solve this issue, thanks in advance.</p>