Well it's the following, I have a .JS file in my project.
I'm calling it in HEAD SO:
<script type ="text/javascript" src="~/JS/validacao.js"></script>
within this validation. JS has a masquerade function.
and put the following event in Textbox.
this.TxtCEP.Attributes.Add("onkeypress", "Mascara(CEP, TxtCEP);");
<asp:TextBox ID="TxtCEP" runat="server" style="margin-left: 66px" Width="231px" TextMode="Number" MaxLength ="8"></asp:TextBox>
Mascara Function
function Mascara(formato, objeto) {
campo = eval (objeto);
// CEP
if (formato=='CEP'){
var CodCar = event.keyCode;
if (CodCar < 48 || CodCar > 57) {
campo.focus();
event.returnValue = false;
}
separador = '-';
conjunto1 = 5;
if (campo.value.length == conjunto1) {
campo.value = campo.value + separador;
}
}
}
But it is not working.
Am I doing it right?