-1
In the HTML file I inserted the script of the JS file where my function is, so I can connect one file to another.
<script src="./main.js"></script>
In the cep input field the id="cep"
.
<label for="cep">CEP</label>
<input type="text" id="cep" required>
In the JS file I used the function document.getElementById('cep').addEventListener('focusout',pesquisarCep);
but informs that it is void.
I don’t know where else to locate the problem.
If you call the element before it exists, it will be null. For example, if you call the JS in the document HEAD and the
document.getElementById('cep')
before the elementcep
exist on the page.– Sam
Thank you, I put it in the end and it worked.
– Carla Souza