But I'm not sure how to do that.
Example of what I want to do:
<!DOCTYPE html>
<html>
<body>
<script>
let showMessage = false;
</script>
{% if showMessage %}
faça isso
{% else %}
faça aquilo
{% endif %}
</body>
</html>
I know that with python it's very simple, however I'm using a webservice in JS
registrations.js:
// RETORNO DA API EM JSON - AUTOCOMPLETE DOS INPUT
let showMessage = false;
function callback(content) {
if (!("erro" in content)) {
const Inputs = document.querySelectorAll('form input');
Inputs[2].value = (content.logradouro);
Inputs[4].value = (content.complemento);
Inputs[5].value = (content.bairro);
Inputs[6].value = (content.localidade);
Inputs[7].value = (content.uf);
} else {
formClean();
showMessage = true; <---- aqui que mudo o valor da variavel
}
}
// FAZ BUSCA DO CEP - ONBLUR
function searchByCep() {
const cep = document.querySelector('#id_zip_code');
if (cep.value != "") {
let script = document.createElement('script');
script.src = 'https://viacep.com.br/ws/' + cep.value + '/json/?callback=callback';
document.body.appendChild(script);
}
};