Skip to content

Instantly share code, notes, and snippets.

@uhtred
Created October 8, 2014 22:30
Show Gist options
  • Save uhtred/701ff8897d925ecb5f79 to your computer and use it in GitHub Desktop.
Save uhtred/701ff8897d925ecb5f79 to your computer and use it in GitHub Desktop.
JS: jQuery Mask Plugin São Paulo
var maskBehavior = function(val) {
return val.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-00009';
},
options = {
onKeyPress: function(val, e, field, options) {
field.mask(maskBehavior.apply({}, arguments), options);
}
};
$('.phone').mask(maskBehavior, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment