Rose, if you open the developer toolbar of your browser, go to the network tab and do some tests on the page, you will see which URL is being called and the parameters. I extracted a passage for simulation, as below:
$.post('https://cadastro.r7.com/ajax/validate/cpf'
, { 'user.documentNumber':'111.111.111-11', 'user.birthDate':'01/01/1900' }
, function (data) {
if (data == '') {
alert('Válido');
} else {
// Este trecho converte códigos de acentos
// (ex.: á ç) nos seus respectivos caracteres.
var div = document.createElement('div');
div.innerHTML = data.message;
alert(div.innerText);
}
}
);
This section will only work on the website of R7 (console tab of the developer tools) because, for security, the browser blocks "cross-Domain" requests. There are libraries to circumvent such restrictions, but there is always the downside that as the R7 portal did not provide this feature in order to sharelo with third parties, one day stop working your validation and you have to study the code again and make the necessary changes. I don’t know if it’s worth the risk.
You can create a page on your server to send the data to the Revenue, including captcha, and recover the return but you fall into the same disadvantage of being vulnerable to the Revenue changes. An example in C#, but for CNPJ (worth to understand how complex the mission is): http://fabianonalin.net.br/Fontes/consultar-cnpj
There may be third-party (paid) services that provide a Webservice to perform such queries, but I don’t know how much worth doing this validation. You can make it as difficult as possible for the user to fill in incorrect data by performing the same validation on the server, but if the user is willing to cheat, there is a risk that the user will use third party data.
When deciding which way to go, update the question to serve as a reference for other programmers who find this page.
In fact, CPF has no direct association with the date of birth. What exists to validate the CPF is the algorithm Module 11: http://www.goulart.pro.br/cbasico/Calculo_dv.htm
– Leonel Sanches da Silva
See the id of this birth date and Cpf inputs and do a search in js and see the procedure
– Thalles Daniel
So I also thought it didn’t exist; but after trying to register without wanting to enter the wrong birth date and I couldn’t continue it was only possible to create the account when I put the correct birthday date. On the website of the recipe I could only consult the situation of Cpf with the date of birth but there is already the date in the database and R7 no.
– Rose
R7 probably validates with revenue data to see if the information is consistent
– Jeferson Assis
Be that as it may; interesting how this part is made, gives more security when it comes to obtaining the data decreasing entries with errors.
– Rose
I wouldn’t use it. CPF already has a validation mechanism that prevents errors. If you want to validate DATA based on the recipe search to see if it matches, it would be a DATA validation. Even this, I would not use - unless it was a requirement that the date follow what is recorded in the recipe. In this case the API to be used should be provided.
– RSinohara
Another comment, unless it’s like Jeferson Assis said, maybe the site uses a logic that associates the number of the CPF with a range of year of birth. Maybe there is this, as it could be for car plates. I would have reservations when the effectiveness.
– RSinohara
I searched on the Internet I found nothing about it :-/
– Rose