Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/03/2009, 12:22
Avatar de rol2007
rol2007
 
Fecha de Ingreso: mayo-2007
Ubicación: Santiasco CHILE
Mensajes: 300
Antigüedad: 17 años, 10 meses
Puntos: 4
Validar numeros

hola tengo esta función que me valida que ingresen solo numeros, el problema es que solo funciona en IE y en firefox no puedo ingresar puntos decimal

si alguien sabe como se debiera validar se lo agradezco he buscado los códigos ascii y no encuentro nada para que los tome

gracias

Código:
<script>
function KeyIsDecimal2(evt )
{
	var isNav = (navigator.appName.indexOf("Netscape") != -1)
	var isIE = (navigator.appName.indexOf("Microsoft") != -1)

	if (isNav) {
		if ( evt.which == 13 || evt.wich == 46 || evt.which == 8 || evt.wich == 110 ||(evt.which >= 48 && evt.which <=57) ){
			if (evt.which == 46 && txt.indexOf('.')!=-1) return false;
			return true;
		}
		return false;
	}
	else if (isIE){
		evt = window.event;
		if ( evt.keyCode == 13 || evt.keyCode == 46 || evt.keyCode == 8 || (evt.keyCode >= 48 && evt.keyCode <= 57) ){
			if (evt.keyCode == 46 && txt.indexOf('.')!=-1) return false;
	
			return true;
		}
		return false;
	}
	else {
		alert("Su browser no es soportado por esta aplicación")
		}
	return false
}
</script>
	<tr>
				<td> Monto: </td><td><input type="text" name="monto" 
<input name="txt_rut" maxlength=8 size=8 tabindex=1 onkeypress="KeyIsDecimal2(event)"></td> 
 
 
			 <br>
			 

			<td><input type="button" name="enviar" value="Guardar">
			</tr>
__________________
Saludos
desde Chile