Check username / email

I am new to html programming and development and would like to ask a question that some might consider stupid.

Here:

I have a registration form that is validated using the jQuery validation plugin. This form has an email input and password that will be used as login credentials.

What I would like to do is check if this email is available in my database (MySQL). If so, the user will be prompted to insert another email. If this is not the case, the user will continue to request this email. How should I do it? Should I include the form in the form? For example, should I have a built-in form with a "Check availability" button, for example, like registering for Gmail?

Is there a standard procedure? Please suggest a good and easy way.

+3
source share
2 answers

You can use ajax to access the server side of the script to check the availability of email, and then display an error / error message depending on the response received from the server.

As, for example, in the case of blurring the email field (when it loses focus), you can turn off an event that has a server-side call using ajax, and then depending on the answer you can hide / show which contains an error message.

Your email field might look like this:

<input type="text" name="email" class="email" />

The jQuery code looks something like this:

$("input.email").blur( function() {
  $.ajax({
    url: 'ajax/getData.php?email=' + $(this).val(),
    success: function(data) {
      // Hide/show the error div over here
    }
  });
});
+2
source

, HTTP- jQuery, - (onblur). , (, ), .

:

  • , , .
  • , , , . :)
+1

Source: https://habr.com/ru/post/1760033/


All Articles