14/09/2006, 13:29
|
| | Fecha de Ingreso: abril-2005 Ubicación: en Santa Cruz - España
Mensajes: 429
Antigüedad: 19 años, 9 meses Puntos: 1 | |
Mira este es mi codigo:
function VerificarNumero(e){
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron =/[0-9]/;
te = String.fromCharCode(tecla);
return patron.test(te);
}
function ValidarNumero(texto,maximo){
var valor = new Number(texto.value);
var maxi = new Number(maximo);
if(valor>maxi){
alert("Aviso: Te pasaste del limite");
texto.value = "0";
texto.select();
document.formulario.vf_cantidad.focus()
}
}
<input name="vf_cantidad" type="text" size="5" maxlength="5" onKeyPress="return VerificarNumero(event)" onchange="return ValidarNumero(this,'5')"/>
Por si acaso no funciona en FIREFOX pero si en INTERNET EXPLORER |