Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

michel diniz

mascara jquery funciona apenas a primeira

Recommended Posts

olá, um erro começou a me dar dor de cabeça, meu código estava funcionando mas de repente o código não funcionava mais =/, inclui mais um campo na tabela dai o jquey estava colocando mascaras apenas no primeiro campo do código e não consigo resolver, se alguém conseguir me ajudar fico muito agradecido abçs. (obs a extenção é .php)

 

código jquey:

 

$(document).ready(function() {
$('.documento + span')
.css({display: 'none',
border: '1px solid #000',
padding: '2px 4px',
background: '#white',
marginLeft: '10px',
fontSize: '14px'
});


$('.fax + span')
.css({display: 'none',
border: '1px solid #000',
padding: '2px 4px',
background: '#white',
marginLeft: '10px',
fontSize: '14px'
});


$('.telefone + span')
.css({display: 'none',
border: '1px solid #000',
padding: '2px 4px',
background: '#white',
marginLeft: '10px',
fontSize: '14px'
});


$('.celular + span')
.css({display: 'none',
border: '1px solid #000',
padding: '2px 4px',
background: '#white',
marginLeft: '10px',
fontSize: '14px'
});


////////////////////////


$('.documento').focus(function() {
$(this).next().fadeIn(1500);
}).blur(function() {
$(this).next().fadeOut(1500);


}); 


$('.fax').focus(function() {
$(this).next().fadeIn(1500);
}).blur(function() {
$(this).next().fadeOut(1500);


});


$('.telefone').focus(function() {
$(this).next().fadeIn(1500);
}).blur(function() {
$(this).next().fadeOut(1500);


});


$('.celular').focus(function() {
$(this).next().fadeIn(1500);
}).blur(function() {
$(this).next().fadeOut(1500);


});


//////////////////////////
$('.celular').mask("(999) 9999-99999");  //aqui começo a postar as mascaras mas apenas esse funciona os demais a baixo não faz nada
$('.documento').mask("99999999999999");


});
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
código html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link  rel="stylesheet" href="CSS/css.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>advocacia_work_pag</title>
<script type="text/javascript" src="scripts/jquery-1.11.3.js"></script>
<script src="scripts/jquery.maskedinput-1.1.4.pack.js" type="text/javascript"></script>
<script type="text/javascript" src="http://www.geradorcpf.com/jquery.maskedinput-1.1.4.pack.js"></script>
<script src="scripts/jscadastro.js" type="text/javascript"></script>


</head>


<form name="cadastro" method="post">


<table border="1" style="margin:0 auto">
<tr>
     <td style="width:200px; text-align:right;"><qq style="color:#F00">*</qq>Nome Completo:
        </td>
        <td style="width:500px; text-align:left"><input name="nome" type="text" class="nome" id="nome" style="width:300px" maxlength="45" />
        </td>
    </tr>
    
    <tr>
     <td style="width:200px; text-align:right;"><qq style="color:#F00">*</qq>CPF/CNPJ:
        </td>
        <td style="width:500px; text-align:left"><input type="text" class="documento"  maxlength="14"  /><span>Digite apenas números</span>
        </td>
</tr>
    
    <tr>
     <td style="width:200px; text-align:right;"><qq style="color:#F00">*</qq>Telefone:
        </td>
        <td style="width:500px; text-align:left"><input type="tel" class="telefone"  placeholder="(DDD) 9999-9999" maxlength="13" /><span>Digite apenas números</span>
        </td>
    </tr>


<tr>
     <td style="width:200px; text-align:right;"><qq style="color:#F00">*</qq>Celular:
        </td>
        <td style="width:500px; text-align:left"><input type="tel" class="celular"  placeholder="(DDD) 9999-99999" maxlength="15" /><span>Digite apenas números</span>
        </td>
    </tr>
    <tr>
     <td style="width:200px; text-align:right;">Fax:
        </td>
        <td style="width:500px; text-align:left"><input type="tel" class="fax"  placeholder="(DDD) 9999-9999" maxlength="13" /><span>Digite apenas números</span>
        </td>
    </tr>
    
</table>
</form>
<br />
           
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você notou que declarou duas vezes o masked input no seu header?

<script src="scripts/jquery.maskedinput-1.1.4.pack.js" type="text/javascript"></script>
<script type="text/javascript" src="http://www.geradorcpf.com/jquery.maskedinput-1.1.4.pack.js"></script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.