-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpf.html
More file actions
63 lines (52 loc) · 1.34 KB
/
cpf.html
File metadata and controls
63 lines (52 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset=utf-8 />
<title>Consultar Nome por CPF</title>
<style>
input {
font-size: 15px;
width: 400px;
}
</style>
</head>
<body>
<form>
<p>
<input type="text" name="cpf" id="cpf" placeholder="CPF"></input>
</p>
<p>
<input type="text" name="nome" id="nome" placeholder="Nome" disabled="disabled"></input>
</p>
<p id="status"></p>
</form>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://irql.bipbop.com.br/js/jquery.bipbop.min.js"></script>
<script>
$(function(){
function validCPF (cpf) {
return cpf.match(/^\d{3}\.?\d{3}\.?\d{3}\-?\d{2}$/);
}
BIPBOP_KEY = 'c09a99c7982f40408bf5488d6ed8c5cd';
$('#cpf').keyup(function(){
var cpf = this.value;
if (validCPF(cpf)) {
$().bipbop("SELECT FROM 'BIPBOPJS'.'CPFCNPJ'", BIPBOP_KEY, {
data: { documento: cpf },
success: function(data) {
var nome = $(data).find("body nome").text();
var exception = $(data).find("header exception").text();
if (exception) {
exception = exception.replace(/, t/, '. T');
$('#status').text(exception);
} else {
$("#nome").val(nome);
}
}
});
}
});
});
</script>
</body>
</html>