Validation of form in real time with php?

0

Assuming I have a form with some fields, and one of these fields is a CPF field.

<input name="cpf" 
       data-input-mask="cpf" 
       data-input-field="cpf"  
       data-input-validator="cpf" 
       value="" 
       class="form-control input-field" 
       type="text">

Currently, by my framework, I identify the 'input-mask' in the jQuery event keyup and focus , I add the mask, and also, with each change in the input data, I make a request for a caller in php, which does the validation according to 'input-validator' , the response of this validation is a JSON containing 'true' or 'false' and a code of the error message, something like '0546' , message that is stored in a JSON file. >

This method worked well for a while, however, things started to get longer and the forms more complex, causing performance to fall heavily due to the number of requests.

With some research I found things like:

WebSocket.

Plugin jQuery validator (personally I found it horrible).

Validate with JAVA (?) (It did not make much sense to me JAVA + PHP, but was indicated by a programmer friend)

Validate with pure javascript (It's the easiest way, but it falls into I can not reuse my PHP methods).

In the way I use, the PHP validation methods of the ajax requests for each input are the same as those used after submitting the form.

What is the best option (without leaving jQuery + PHP) to validate fields, among other features like updating graphics in real time?

If, ajax requests timed (or fired), how to improve their performance?

If webSocket, I know absolutely nothing about, which framework / package / PHP plugin provides me with good documentation? (I tried using cboden / ratchet but without success).

If another mode, what would be recommended for an application that will rarely have more than 20 concurrent accesses and has a dedicated server?

PS: The problem of many current ajax requests is more client-side than server-side.

    
asked by anonymous 16.08.2017 / 22:23

0 answers