Comments (18)
Pessoal tente dessa forma (aprovado e testado):
var options = {
onKeyPress: function (cpf, ev, el, op) {
var masks = ['000.000.000-000', '00.000.000/0000-00'];
$('.cpfOuCnpj').mask((cpf.length > 14) ? masks[1] : masks[0], op);
}
}
$('.cpfOuCnpj').mask('000.000.000-000', options);
StackOverflow: https://pt.stackoverflow.com/a/200389/54019
from jquery-mask-plugin.
Ficou faltando adicionar os Scripts Externos - jquery e Mask...
Aqui tá certo já >>> http://jsfiddle.net/zWPs7/2/
Tentei de um modo diferente ( http://jsfiddle.net/zWPs7/3/ ) mas não deu tb:
var options = {
onKeyPress: function(cpf, ev, el, op){
if(cpf.length>12) console.log(cpf.length);
var masks = ['000.000.000-000', '00.000.000/0000-00'],
mask = (cpf.length>14) ? masks[1] : masks[0];
el.mask(mask, op);
}
}
$('#cnpj_cpf').mask('000.000.000-000', options);
from jquery-mask-plugin.
Obrigado, @pyetrosafe!
from jquery-mask-plugin.
@germanolucas fiz um teste com outra versão (0.11.5) funcionou certinho ( http://jsfiddle.net/zWPs7/6/ )... é a versão nova que está com problemas... Esperar o igor dar uma olhada!!!
from jquery-mask-plugin.
É. Eu testei com a versão 0.11.4, funciona correto.
from jquery-mask-plugin.
Resolve? http://jsfiddle.net/zWPs7/5/
from jquery-mask-plugin.
O fiddlejs está na ultima versão.
Regards,
Igor Escobar
*Software Engineer
*
- http://blog.igorescobar.com
- http://www.igorescobar.com
- @igorescobar http://www.twitter.com/igorescobar
On Wed, Sep 4, 2013 at 9:17 AM, Pyetro Costa [email protected]:
@igorescobar https://github.com/igorescobar Atualizou a versão?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-23784621
.
from jquery-mask-plugin.
@igorescobar, o código que você postou resolve em parte. Você pode fazer um teste em http://jsfiddle.net/zWPs7/5/ Digite um CPF 12312312300, depois pressione a tecla Home, a formatação que deveria ficar a do CPF muda para 12.312.312/300 por conta da alteração sugerida por você. Também fiz um teste aqui na minha aplicação usando a última versão (v1.1.2) usando "d.byPassKeys = [];". A "formatação tardia" ao deletar caracteres continua.
from jquery-mask-plugin.
Vou dar uma olhada hoje! Não mude de canal ;)
from jquery-mask-plugin.
Teste com a nova versão v1.1.3:
http://jsfiddle.net/zWPs7/7/
from jquery-mask-plugin.
Ok, @igorescobar, agora funcionou corretamente.
from jquery-mask-plugin.
Eu estou tentando fazer exatamente a mesma coisa, mas quando insiro o ultimo dígito ele aplica a máscara do cnpj e então volta a máscara do cpf.
Estou fazendo algo errado?
from jquery-mask-plugin.
o JQuery-Mask-Plugin é multi-propósito por se destinar à aplicação de vários tipos de máscara. Portanto, pode ter havido alguma alteração no plugin para atender uma outra necessidade. Tente usar uma versão diferente do arquivo, como no exemplo abaixo.
http://jsfiddle.net/znuph72f/2/
Em Terça-feira, 23 de Dezembro de 2014 19:31, dunebuddy <[email protected]> escreveu:
Eu estou tentando fazer exatamente a mesma coisa, mas quando insiro o ultimo dígito ele aplica a máscara do cnpj e então volta a máscara do cpf.http://jsfiddle.net/znuph72f/Estou fazendo algo errado?—
Reply to this email directly or view it on GitHub.
from jquery-mask-plugin.
A mesma coisa acontece comigo. Detalhe estou usando Bootstrap.
from jquery-mask-plugin.
Continua não funcionando. Acabei de baixar e testar
from jquery-mask-plugin.
estou tentando adaptar para telefone fixou ou celular.. mas nao estou conseguindo..
alguma ideia de como arrumar ?
Outra duvida é o que são os parametros ev,el ?
Como nao conheco a linguagem só c# e javascript.. então peço ajuda a todos.. de como poderia detectar se existe o 9 no 3o digito.. aí formataria como celular.. ou se tem 11 digitos ou 10 digitos..
_
var optFixoOuCelular = {
onKeyPress: function (tel, ev, el, op) {
var masks = ['(99)9999-9999', '(99)9.9999-9999'];
$('.FixoOuCelular').mask((tel.length > 10) ? masks[1] : masks[0], op);
}
}
$('.FixoOuCelular').mask('(99)9.9999-9999', optFixoOuCelular);
_
from jquery-mask-plugin.
@jorgesomers na documentação já tem um exemplo aqui.
Veja rodando: JsFiddle.
from jquery-mask-plugin.
Ola caro @matmiranda muito obrigado !
Valeu mesmo.. está lindo .. ficou muito bacana mesmo..
Obrigado !
from jquery-mask-plugin.
Related Issues (20)
- Cant get the money mask to work HOT 2
- Multiple mask in data-mask using array
- .mask() method doesn't work on inputs with type "number" HOT 2
- jQuery 'input' event receiving unexpected value
- Replace lowercase with Uppercase HOT 1
- Mask allowing partially filled input to be submitted
- Special Characters in the pattern? HOT 1
- jQuery Mask Input
- Masking hour and prevent incorrect hours HOT 4
- 'Uncaught TypeError: $(...).mask is not a function' error on .NET Core MVC app. HOT 4
- Donations dont work on your page
- Ns
- mask('0.0.0') transform to 0.00??
- How to remove Masking on Form Submit HOT 1
- Additional server-side (PHP) checking libraries HOT 1
- Data mask reverse on Phone with DDD
- Can i do this kind of mask ?
- AVAST is understanding that it is a virus! HOT 7
- How to apply mask to string value not element
- Automatically enter the required numbers/letters?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-mask-plugin.