Código HTML:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script> function validacion(formulario, nombre, oculto, tipo) { if(tipo == "check"){ if(formulario.nombre.value==""){ document.formulario.nombre.border = "red solid 2px" document.formulario.oculto.value = 0 } } } </script> </head> <body> <form name="f"> <input type="text" name="t" onblur="validacion(f, t, h, check)" /> <input type="hidden" name="h" /> </form> </body> </html>