Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/02/2011, 13:44
Avatar de ale_dla
ale_dla
 
Fecha de Ingreso: abril-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 189
Antigüedad: 15 años
Puntos: 3
Mostrar nombre ingresado

Hola!
Estoy haciendo un ejercicio en el cual me tiene que mostrar el nombre que ingreso sino muestra el mensaje de error que Escribe tu nombre.
Mi codigo es este:
Código PHP:
<html>
<
head>
<
title>Javascript 15</title>
<
script type="text/javascript">
/* validar si se ingresa en el campo de nombre */

function validarNombre(){

    if ( 
document.formulario.nombre.value == "") { // si en el campo nombre no hay nada

        
document.getElementById('mensaje_error').innerHTML='<b style=color:red;>Escribe tu nombre.</b>';
        
//alert("Escribe tu nombre");
        
document.formulario.nombre.focus();
        return 
false;

    }else{
    
        
alert('Tu nombre es: ',nombre);
        
//document.getElementById('nombre').innerHTML='<span style=color:green;>Tu nombre es: ',nombre,'</span>';
        
return true;

    }
    
 
document.formulario.submit(); 
    }

</script>
</head>
<body>
    <table border="0"/>
    <form id="formulario" name="formulario" method="post" onSubmit="return validarNombre()">
    <b id="mensaje_error"></b>
    <tr>
        <td>Nombre:</td>
        <td><input type="text" name="nombre" id="nombre"/></td>
    </tr>
    <tr>
        <td rowspan="2"></td>
        <td><input type="submit" name="enviar" value="Enviar"/></td>
    </tr>
    </table>
    </form>
</body>
</html> 
El problema es que no me muestra el nombre que ingreso.
Quien pueda ayudarme se los agradezco,