![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
21/01/2016, 08:43
|
| | Fecha de Ingreso: junio-2007
Mensajes: 253
Antigüedad: 17 años, 7 meses Puntos: 0 | |
Respuesta: Validar solo números. Hola jmg1189,
Aún dejando (key >= 48 && key <= 57), sigue permitiendo el ingreso de estos caracteres $%&.
Pero encontré esta solución:
function soloNumeros(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla == 8) return true;
patron = /\d/;
te = String.fromCharCode(tecla);
return patron.test(te);
}
<asp:TextBox ID="txtRango1" runat="server" MaxLength="4" Text='<%#FormatNumber(Eval("mayor_igual"),0) %>'
onkeypress="return soloNumeros(event);"></asp:TextBox>
Gracias. |