Please, where I can change this mask function to avoid the user type 0 (zero) as a first number?
This is a mask function to format the input at this format:
(99) 9999-9999 or (99) 99999-9999 Once here in Brazil the celphone has now 9 digits and normal phones 8 digits. But the city code (between parentheses) could NOT start with 0 (zero), otherwise will mess up the phone number.
// telefone com 9 digitos 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); } }; $('#telefone').mask(SPMaskBehavior, spOptions); Here's the mask link