Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/07/2008, 07:12
Avatar de derkenuke
derkenuke
Colaborador
 
Fecha de Ingreso: octubre-2003
Ubicación: self.location.href
Mensajes: 2.665
Antigüedad: 21 años, 4 meses
Puntos: 45
Respuesta: Activar boton si campos llenos y correctos

Hola de nuevo:

Cuando trabajamos con códigos tan grandes lo mejor es postear un pequeño ejemplo que resuma nuestra duda, así es más fácil obtener ayuda y se ven más claras las cosas. En este código se ve como funciona el asunto:

Código PHP:
<!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" xml:lang="es" lang="es">
<
head>
<
meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" />
<
meta name="Author" content="derkeNuke" />
<
title>P&#225;gina nueva</title>
<style type="text/css">

</
style>
</
head>

<
body>

<
form name="fr">
    <
input type="text" name="caja1" />
    <
input type="text" name="caja2" />
    <
button id="btnEnviar" type="submit">enviar</button>
</
form>

<
script type="text/javascript">
<!--

function 
activarBoton() {
    if(
verificar()) {
        
btnEnviar.disabled=false
    
}
    else {
        
btnEnviar.disabled=true
    
}
}

function 
verificar() {
    if( 
caja1.value==="" )
        return 
false;
    if( 
caja2.value==="" )
        return 
false;
    return 
true;
}

var 
btnEnviar document.getElementById("btnEnviar");
btnEnviar.disabled true;
var 
caja1 document.fr.caja1;
var 
caja2 document.fr.caja2;
caja1.onkeyup caja2.onkeyup activarBoton;


// -->
</script>

</body>
</html> 


Un saludo.
__________________
- Haz preguntas inteligentes, y obtendrás más y mejores respuestas.
- Antes de postearlo Inténtalo y Búscalo.
- Escribe correctamente tus mensajes.