Last active
April 16, 2018 21:11
-
-
Save breim/6e1d99123bde056f2767 to your computer and use it in GitHub Desktop.
Gem BR CEP Autocomplete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// COLOCA ISSO NA VIEW QUE VAI BUSCAR O CEP | |
function jsBuscaCep() { | |
var cep = document.getElementById( "ID DO CAMPO QUE ESTÁ o CEP" ).value; | |
$.getJSON("http://cep.republicavirtual.com.br/web_cep.php?formato=query_string&cep=" + cep, | |
function ( data ) { | |
console.log(data); | |
$("#user_endereco").val(data.tipo_logradouro + ' ' + data.logradouro); | |
$("#user_bairro").val(data.bairro); | |
$("#user_cidade").val(data.cidade); | |
$("#user_estado").val(data.uf); | |
$("#user_numero").focus(); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment