I have these methods in my js:
function soloNumeros(e) {
var key = window.Event ? e.which : e.keyCode
return (key >= 48 && key <= 57);
}
function soloPegarNumeros(n) {
permitidos = /[^0-9.]/;
if (permitidos.test(n.value)) {
alert("Solo se puede ingresar numeros");
n.value = "";
n.focus();
}
}
$("#txtDNI").keypress(soloNumeros(event));
$("#txtDNI").blur(soloPegarNumeros(this));
And in my view I have this:
<asp:TextBox type="text" autofocus="autofocus" runat="server" ID="txtDNI" MaxLength="8" AutoPostBack="true"/><br />
What I'm doing is validating that you do not write or paste letters in the "txtDni" textbox. But I do not know why he does not get the jquery methods.