0
Good morning. I need to validate the typed ZIP code in an input. If the ZIP code is equal to 35000-000, you must clear the input and send an Unavailable ZIP message. Is there a way to do this using the HTML Pattern attribute? How to do?
void validaCEP(){
var cep = document.commentForm.cep
if (cep == '35300-000'){
alert('CEP Indisponível')
document.commentForm.cep.focus
alert(cep);
}
}
Thank you.
Have you tried to do anything? Could you add the real problem to the question? Why is the above mentioned zip code invalid? It has the correct formatting of a zip code.
– Woss
Business rule.
– Lucas Augusto Coelho Lopes
Dude, I use https://viacep.com.br/ and it works great, I recommend it. It will save you service
– Ricardo
I used it, but I never had to do this type of validation, with some ZIP code restriction. I need to block the registration of this ZIP code. Is there any way to restrict this on the frontend?
– Lucas Augusto Coelho Lopes