Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Máscaras ER */
- function mascara(o,f){
- v_obj=o
- v_fun=f
- setTimeout("execmascara()",1)
- }
- function execmascara(){
- v_obj.value=v_fun(v_obj.value)
- }
- function mtel(v){
- v=v.replace(/\D/g,""); //Remove tudo o que não é dígito
- v=v.replace(/^(\d{2})(\d)/g,"($1) $2"); //Coloca parênteses em volta dos dois primeiros dígitos
- v=v.replace(/(\d)(\d{4})$/,"$1-$2"); //Coloca hífen entre o quarto e o quinto dígitos
- return v;
- }
- function mCNPJ(v){
- v=v.replace(/\D/g,"");
- v=v.replace(/^(\d{2})(\d)/,"$1.$2");
- v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3");
- v=v.replace(/\.(\d{3})(\d)/,".$1/$2");
- v=v.replace(/(\d{4})(\d)/,"$1-$2");
- return v;
- }
- function mcpf(v) {
- v=v.replace(/\D/g,"");
- v=v.replace(/(\d{3})(\d)/,"$1.$2");
- v=v.replace(/(\d{3})(\d)/,"$1.$2");
- v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2");
- return v;
- }
- function mCEP(v){
- v=v.replace(/\D/g,"");
- v=v.replace(/^(\d{2})(\d)/,"$1.$2");
- v=v.replace(/\.(\d{3})(\d)/,".$1-$2");
- return v;
- }
- function mNum(v){
- v=v.replace(/\D/g,"");
- return v;
- }
- function id( el ){
- return document.getElementById( el );
- }
- window.onload = function(){
- if (id('acf-field_59dd151f7f5c3')) {
- id('acf-field_59dd151f7f5c3').onkeypress = function(){
- mascara( this, mtel );
- }
- }
- if (id('acf-field_59dd15337f5c4')) {
- id('acf-field_59dd15337f5c4').onkeypress = function(){
- mascara( this, mtel );
- }
- }
- if (id('telefone')) {
- id('telefone').onkeypress = function(){
- mascara( this, mtel );
- }
- }
- if (id('celular')) {
- id('celular').onkeypress = function(){
- mascara( this, mtel );
- }
- }
- if (id('cpf')) {
- id('cpf').onkeypress = function(){
- mascara( this, mcpf );
- }
- }
- if (id('cep')) {
- id('cep').onkeypress = function(){
- mascara( this, mcep );
- }
- }
- if (id('cnpj')) {
- id('cnpj').onkeypress = function(){
- mascara( this, mcnpj );
- }
- }
- }
Add Comment
Please, Sign In to add comment