Form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Nuevo Usuario Laboral</title> <script src="js/reg_validar.js" type="text/javascript"></script> </head> <body> <h1>Información general</h1> <p> </p> <form action="#" name="registro"> <table width="600" border="0"> <tr> <td width="150">Nombre:</td> <td width="300"> <input name="nombre" type="text" value="" size="40" onBlur="validate_form1(this.value,'nombre')"/> </td> <td width="150"><div id="eNombre" ></div> </td> <!--Msg--> </tr> <tr> <td>Apellido:</td> <td> <input type="text" name="apellido" id="apellido" size="40" onBlur="validate_form1(this.value)"/> </td> </tr> <tr> <td>Cedula:</td> <td> <input type="text" name="cedula" id="cedula" onBlur="validate_form1(this.value)"/> </td> </tr> </table> </form> </body> </html>
JS:
function validate_form1(Valor, Campo){
if (Valor==""){
document.getElementById('eNombre').innerHTML = "Requerido";
registro.nombre.focus();
}
}
As u can see, it should work just fine. It works indeed, the problem is that i need to show several msg, but i don't want to make a code for each input. So the question is: How do i write "registro.(Campo).focus()" ?. The var "Campo" will be the name of the input, "registro" is the name of the form. I've try to do it, but it just doesn't work.


Sign In
Create Account

Guest_GerarD_91_*
Back to top










