Trying to validate the login.

Validation consists of 3 parts.

  1. Login verification for characters
  2. Login verification through regular expression
  3. Sending data to the server and checking the busy login.

It may be such a situation that until the answer comes from the server, the user deletes several characters and the check will return an error according to item 2 (Login verification through regular expression)

Can I somehow cancel the request to the server at this moment?

Edit (more details)

Login has 4 states:

  1. Empty
  2. Does not fit
  3. Free
  4. Busy

Each of the 4 states has its own string parameter. The first two checks pass locally. If they have passed a request is sent to the server.

Block UI is not desirable.

  • Forbid (disable) the user to touch something until the answer from the server comes! - Alexander Chernin
  • The request cannot be canceled, it has already flown away and even if you send a messenger with a mail in the trail, by that time the request can already be processed. In short, it is still a trouble, better to dizablite, and if the answer from the server does not come, then on the timer inquire - Alexander Chernin
  • Why are the first two checks done on the server? they should be done on the client, and only the third on the server. and now after sending the data (confirmation of input fidelity), all three are done on the server side. - Vladimir Klykov
  • @ Vladimir Klykov I understand that the first 2 he has done on the client, which is logical in principle - Alexander Chernin
  • @AlexanderChernin Perhaps so, it seemed to me otherwise, actually what the problem is then I don’t see from the word at all ... sending the answer from the server is not just “true / false”, but the login itself that was checked, and if it has already changed on the client - reject check result as unnecessary \ invalid. - Vladimir Klykov

1 answer 1

Track input and, depending on this, process the response from the server, as well as cancel previous requests.

For example, a username is entered, passing checks -> A request is sent -> something else is entered -> the request has not yet completed - canceled -> a new request -> something else is entered -> the request has already completed, but since the incoming data others do nothing with the answer -> new request -> nothing has been entered -> we process the answer.

  • I was only interested in the cancellation method. Thanks for the help! - Victor Mishustin