Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/01/2008, 19:19
Avatar de mauled
mauled
 
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 11 meses
Puntos: 33
De acuerdo Re: problema validacion

jeje ya funciona echale un ojo

Código HTML:
<html>
<body> 
<script language="javascript">
<!--
  var colorMal="#FFFFEE"; 
  var colorBien="white"; 

  function prueba(){
  var flag = true;

    if(document.form3.cod_clase.value == "0000" || document.form3.cod_clase.value =="" ||document.form3.cod_clase.value.length<4)
    {
      document.getElementById('cod_clase_err').innerHTML = '<strong><font color="#DC5454">- Codigo Clase no valido</font></strong>'; 
      document.forms[0].elements["cod_clase"].style.background=colorMal;
      document.forms[0].elements["cod_clase"].style.borderColor="#C13D12";
      flag = false
     
    }else 
    {
      flag = true;
      document.forms[0].elements["cod_clase"].style.background=colorBien;
      document.forms[0].elements["cod_clase"].style.borderColor="#C0C0C0";
      
    }
 
     if( document.form3.nombre_clase.value ==""   )
    {
      document.getElementById('nombre_clase_err').innerHTML = '<strong><font color="#DC5454">- nombre_clase no valido</font></strong>'; 
      document.forms[0].elements["nombre_clase"].style.background=colorMal;
      document.forms[0].elements["nombre_clase"].style.borderColor="#C13D12";
      flag = false;
      
    }else 
    {
      flag = true;
      document.forms[0].elements["nombre_clase"].style.background=colorBien;
      document.forms[0].elements["nombre_clase"].style.borderColor="#C0C0C0";
      
    }
 

    if(  document.form3.jerarquia.value ==""  )
    {
      document.getElementById('jerarquia_err').innerHTML = '<strong><font color="#DC5454">- jerarquia no valido</font></strong>'; 
      document.forms[0].elements["jerarquia"].style.background=colorMal;
      document.forms[0].elements["jerarquia"].style.borderColor="#C13D12";
      flag = false;
      
    }else 
    {
       flag = true;
       document.forms[0].elements["jerarquia"].style.background=colorBien;
       document.forms[0].elements["jerarquia"].style.borderColor="#C0C0C0";
      
    }    
    
    if(flag)
    {
     
      document.form3.submit();
    }
   

  }
-->
</script>
 
 
  <form name="form3" action="#" method="post">
                      <table width="700"  border="0" cellspacing="2" cellpadding="2">
                    
                        <tr>
                          <td width="150">C&oacute;digo</td>
                          <td width="80"><input name="cod_clase" type="text" maxlength="4" class="small" value=""  id="cod_clase"  ></td>
                          <td width="340"><p id="cod_clase_err">&nbsp;</p>
                        </tr>
                        <tr>
                          <td>Nombre</td>
                          <td><input name="nombre_clase" type="text" maxlength="16" size="25" value="" id="nombre_clase" alt="blank"></td>
                          <td width="340"><p id="nombre_clase_err">&nbsp;</p>
                       </tr>
                        <tr>
                          <td>Jerarqu&iacute;a Clase de Pedido </td>
                          <td><input name="jerarquia" type="text" maxlength="2" class="small" value=""  id="jerarquia"  ></td>
                          <td width="340"><p id="jerarquia_err">&nbsp;</p>
                        </tr>
                    
                       
                        <tr>
                          <td>&nbsp;</td>
                          <td><input name="Enviar" type="button" class="cmd" value="Agregar" onclick="prueba()"></td>
                        </tr>
                      </table></form>
</body>
</html> 
Saludillos.

PD. Cualquier duda o comentario que tengas no dudes en ponerla

Última edición por mauled; 17/01/2008 a las 19:26