Skip to content

Instantly share code, notes, and snippets.

@thallisphp
Created July 8, 2013 20:16
Show Gist options
  • Save thallisphp/5952114 to your computer and use it in GitHub Desktop.
Save thallisphp/5952114 to your computer and use it in GitHub Desktop.
Máscara de telefones com opção de dígito adicional
###
Plugin : https://github.com/igorescobar/jQuery-Mask-Plugin/
bower install jQuery-Mask-Plugin
components/jQuery-Mask-Plugin/jquery.mask.min.js
###
campos = jQuery '.mascara_telefone, #telefone, #celular'
SPphoneMask = (phone, e, currentField, options) ->
if 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"
else
"(00) 0000-0000"
campos.attr 'placeholder', '(00)0000-0000'
campos.mask? SPphoneMask,
onKeyPress: (phone, e, currentField, options) ->
jQuery(currentField).mask? SPphoneMask(phone), options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment