Created
September 14, 2012 20:35
-
-
Save igorescobar/3724610 to your computer and use it in GitHub Desktop.
Mascara Javascript para os novos telefones de São Paulo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using: https://github.com/igorescobar/jQuery-Mask-Plugin | |
// version: v0.5.0+ | |
var SPphoneMask = function(phone, e, currentField, options){ | |
return phone.match(/^(\(?11\)? ?9(5[0-9]|6[0-9]|7[01234569]|8[0-9]|9[0-9])[0-9]{1})/g) ? '(00) 00000-0000' : '(00) 0000-0000'; | |
}; | |
$(".sp_celphones").mask(SPphoneMask, {onKeyPress: function(phone, e, currentField, options){ | |
$(currentField).mask(SPphoneMask(phone), options); | |
}}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ótima mascara.
Que tal implementar o teste aos demais DDDs? http://www.anatel.gov.br/Portal/exibirPortalNivelDois.do?codItemCanal=1794&nomeVisao=Cidad%E3o&nomeCanal=Telefonia%20M%F3vel&nomeItemCanal=Nono%20D%EDgito