Skip to content

Instantly share code, notes, and snippets.

@brunopulis
Forked from kaweski/validPhone.js
Created July 31, 2019 02:47
Show Gist options
  • Save brunopulis/c2b7be103b5caaa29aae66386114c1bd to your computer and use it in GitHub Desktop.
Save brunopulis/c2b7be103b5caaa29aae66386114c1bd to your computer and use it in GitHub Desktop.
Valida telefones do Brasil com DDD, o 9º dígito e obrigatoriamente contendo 9 dígitos, mais espaços e caracteres de separação.
let regex = /^\([1-9]{2}\) 9 [7-9][0-9]{3}\-[0-9]{4}$/;
if( regex.test(c.value) ) {
return null;
} else {
return { phoneError: true };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment