Asi?
Prueba el ejemplo directamente.
Código HTML:
<script language="JavaScript">
///valida campos no vacíos
function valida(c)
{
//alert("validando");
var i,v;
if(c)
{
i=c.name+"obl";
(c.value.length<5)?v="visible":v="hidden";
document.getElementById(i).style.visibility=v;
}
}
///deshabilita botón enviar si campos vacíos
function deshabilita(form)
{
if ((clientes.email.value != "") && (clientes.password.value != "") && (clientes.password.value.length >= 5) && ValidarEmail("email") )
{
clientes.B1.disabled = false;
}
else
{
clientes.B1.disabled = true;
}
}
function ValidarEmail(field)
{
var retVal = true;
var email = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
if (!email.test(document.getElementById(field).value) )
{
retVal = false
}
return retVal;
}
</script>
<form method="post" action="procesar.php" name="clientes">
<table>
<tr>
<td>
email:</td>
<td>
<input type="text" name="email" onKeyUp="deshabilita(this.form);" onblur="document.getElementById('emailobl').style.visibility =(ValidarEmail('email')) ? 'hidden' : 'visible';"></td>
</tr>
<tr>
<td id="emailobl" style="visibility:hidden;"><b>Campo email obligatorio. Asegúrese que el email es válido</b></td>
</tr>
<tr>
<td>
password:</td>
<td>
<input type="password" name="password" onKeyUp="deshabilita(this.form);" onBlur="valida(this);"></td>
</tr>
<tr>
<td id="passwordobl" style="visibility:hidden;"><b>Campo password obligatorio. Debe tener al menos 5 caracteres</b></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" valueenviar" name="B1" disabled></td>
</tr>
</table>
</form>