Esto es todo lo que necesitas. No dejes nunca de validar luego el formulario con php.
Código HTML:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Validar Formulario</title>
<script type="text/javascript">
function Validar(formulario){
if(formulario.nombre.value=="")
alert('Complete el campo \'Nombre\'.')
else if(formulario.apellidos.value=="")
alert('Complete el campo \'Apellidos\'.')
else
formulario.submit();
}
</script>
</head>
<body>
<form id="formulario_A" method="post" action="">
Nombre: <input type="text" name="nombre" id="nombre" /><br />
Apellidos <input type="text" name="apellidos" id="apellidos" /><br />
<input type="button" onclick="Validar(this.form)" value="Validar" />
</form>
</body>
</html>