So, i have this function that checks the CEP (zipcode) triggered by .blur, the thing works great when fired from the console but won't run when imported via external .js. Here's the code:
$('#inputs').on('blur', '#i11', function(){
var cep = $("#i11").val().replace(/\D/g, '');
if (cep != "") {
var validacep = /^[0-9]{8}$/;
if(validacep.test(cep)) {
$.getJSON("//viacep.com.br/ws/"+ cep +"/json/?callback=?", function(dados) {
if (!("erro" in dados)) {
newInput({id: "i13", value: dados.logradouro, type: "hidden"}, '#cacheDB');
newInput({id: "i14", value: dados.bairro, type: "hidden"}, '#cacheDB');
newInput({id: "i15", value: dados.localidade, type: "hidden"}, '#cacheDB');
newInput({id: "i16", value: dados.uf, type: "hidden"}, '#cacheDB');
} else {
formGrabber("#content", loadSequence($("#pid").val()));
}
});
}
}
});
EDIT: Well... Seems that the reason is that the #i11 field is loaded dynamically in the page, so i've updated the question to a more suitable one.
EDIT 2: Updated the code following the instructions on https://stackoverflow.com/a/1207393/5855060 Still not working tho