Objetivo:
Entre as tags "Head" e depois entre as tags do "Javascript" coloque:
E agora é só Add no evento Page_Load do seu webform:
function mascaraCEP(CEP, e)
{
var codigoTecla = (e.which)?e.which:event.keyCode;
if (codigoTecla != 8 && codigoTecla != 46)
{
var valorCEP = CEP.value;
if (valorCEP.length == 2)
{
valorCEP = valorCEP + '.';
CEP.value = valorCEP;
}
if (valorCEP.length == 6)
{
valorCEP = valorCEP + '-';
CEP.value = valorCEP;
}
}
}
TextBox1.Attributes.Add( "onkeydown", @" if(event.keyCode != 8 && event.keyCode != 13 && event.keyCode!=9)
{
MascaraCEP(this);
}");
Nenhum comentário:
Postar um comentário