|    
			
				24/11/2011, 22:57
			
			
			  | 
  |   |  | Colaborador |  |  Fecha de Ingreso: junio-2007 Ubicación: me mudé 
						Mensajes: 8.388
					 Antigüedad: 18 años, 4 meses Puntos: 1567 |  | 
  |  Respuesta: Limitar valor maximo en un input?  
    
Código HTML:
 Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><meta http-equiv="content-type" content="text/html; charset=utf-8" /><script type="text/javascript">//<![CDATA[// con esta función comprobás que sea un númerofunction es_numero(input){return !isNaN(input)&&parseInt(input)==input;}//ahora verificas que sea no sea mayor que 5function comprobar(){ var laedad = document.getElementById('edad').value;  if(es_numero(laedad)){if(laedad > 5){alert("Número mayor que 5\n\rsu número: " + laedad); document.getElementById('edad').value= 5;}} else{alert("Debe ingresar un número");} }//]]>El campo debe de tener un valor y este ser menor ó igual a 5    <br /><input type="text" name="edad" id="edad" onblur="comprobar()"/>
Saludos  
				__________________La voz de las antenas va, sustituyendo a Dios.
 Cuando finalice la mutación, nueva edad media habrá
 S.R.
     |