Skip to content

Instantly share code, notes, and snippets.

@igorescobar
Created September 14, 2012 20:35
Show Gist options
  • Save igorescobar/3724610 to your computer and use it in GitHub Desktop.
Save igorescobar/3724610 to your computer and use it in GitHub Desktop.
Mascara Javascript para os novos telefones de São Paulo
// 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);
}});
Copy link

ghost commented Mar 28, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment