Skip to content

Instantly share code, notes, and snippets.

View Eleisonchr's full-sized avatar
:octocat:
De Boa!

Eleison Christiano Eleisonchr

:octocat:
De Boa!
  • Pnukee Web Services Ltda
  • Cotia / SP / Brazil
  • 11:21 (UTC -03:00)
View GitHub Profile
function telefone_validation(telefone) {
//retira todos os caracteres menos os numeros
telefone = telefone.replace(/\D/g, '');
//verifica se tem a qtde de numero correto
if (!(telefone.length >= 10 && telefone.length <= 11)) return false;
//Se tiver 11 caracteres, verificar se começa com 9 o celular
if (telefone.length == 11 && parseInt(telefone.substring(2, 3)) != 9) return false;