Last active
August 31, 2016 17:08
-
-
Save felipeorlando/b217d14b4fdcd603e8b4fc790d21cf12 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;(function(){ | |
var $phone = $('.phone'); | |
var init = function () { | |
maskAll(); | |
}; | |
var SPMaskBehavior = function (val) { | |
return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009'; | |
}, | |
spOptions = { | |
onKeyPress: function(val, e, field, options) { | |
field.mask(SPMaskBehavior.apply({}, arguments), options); | |
} | |
}; | |
var maskAll = function() { | |
$phone.mask(SPMaskBehavior, spOptions); | |
} | |
$(document) | |
.ready(init) | |
; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment