Hola,
aqui te paso un ejemplo de validacion de formulario que hice yo(en realidad son dos formularios en una misma pagina).La validacion la he hecho en JavaScript
:
Código HTML:
<html>
<head>
<title></title>
</head>
<body bgcolor="yellow">
<script language="javascript">
function validarForm(){
if(document.f2.dni.value=="" || document.f2.contraseña2.value=="")
alert('Debe introducir el DNI y la contaseña');
else
document.f2.submit();
}
</script>
<div align="center">
<img src="C:\Documents and Settings\Administrador\Mis documentos\Proyecto2\images\cabecera.gif">
</div>
<h1 align="center">CURSOS OFERTADOS</h1>
<form name="f1" action="darDeAlta.php" method="post">
<input type="submit" value="Dar de Alta">
</form>
<table width="200">
<form name="f2" action="procesar.php" method="post">
<fieldset>
<legend align="left"><font color="red"><i>Usuarios matriculados</i></font></legend><br>
<tr>
<td><small>DNI:</small></td><td><input type="text" name="dni"></td>
</tr>
<tr>
<td><small>Contraseña:</small></td><td><input type="password" name="contraseña2"></td>
</tr>
<tr>
<!--<td></td><td><input type="submit" value="Entrar"></td>-->
<td></td><td><input type="button" value="Entrar" onclick="validarForm()"></td>
</tr>
</fieldset>
</form>
</table>
</body>
</html>
Si tienes alguna duda no dudes en preguntar.
Saludos