Ver Mensaje Individual
  #8 (permalink)  
Antiguo 27/10/2008, 07:26
Avatar de the_web_saint
the_web_saint
 
Fecha de Ingreso: mayo-2008
Ubicación: localhost/tierra/america/panama
Mensajes: 1.229
Antigüedad: 16 años, 10 meses
Puntos: 43
Respuesta: Problema con un formlario

Te dejo un ejemplo completo, con formulario y todo para que lo pruebes, a mi no me genera ningún error.
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">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Untitled Document</title>
</
head>
<
script>
function 
isEmpty(inputVal
{
  
inputStr inputVal.length
  
var contsps 0    // contador de espacios en blanco
  
for (var 0inputStr i++) 
  {
    var 
oneChar inputVal.charAt(i)
    if (
oneChar == " "
    {
      
contsps contsps 
    
}
  }
  if (
contsps == inputStr
  {
    return 
true
  
}
  else 
  {
    return 
false 
  
}
}

function 
validaForm()
{
    var 
user document.getElementById('username');
    var 
pass document.getElementById('password');

      if (
isEmpty(user.value))
      {
        
alert("El user no debe estar vacío");
        return 
false;
      }
      if (
isEmpty(pass.value))
      {
        
alert("El pass no debe estar vacío");
        return 
false;
      }

}  
</script>
<body>
<form action="validar.php" method="POST" onsubmit="return validaForm();">
<table cellpadding="0px" cellspacing="0px">
    <tr>
        <td>login:&nbsp;</td>
        <td><input type="text" name="username" id="username" maxlength="30" size="25" /></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td>password:&nbsp;&nbsp;</td>
        <td><input type="password" name="password" id="password" maxlength="30" size="25" /></td>
        <td>&nbsp</td>
        <td><input type="submit" value="Login"></td>
    </tr>
</table>
</form>
</body>
</html> 
__________________
..::The Saint::..
El pesimista se queja del viento; el optimista espera que cambie; el realista ajusta las velas.