I'm resposting the bit of code because it had quite a few mistakes because i was typing it.
----- onClick.php ------
<HTML>
<head>
<script language="JavaScript">
function check() {
if (form1.nombre.value == "") {
alert("obligatorio");
return false;
}
form1.submit();
}
</head>
<body>
<FORM METHOD="POST" action="onClick2.php" name="form1">
<input type="text" name="nombre" value="">
<input type="button" name="aceptar" value="aceptar" onClick="check()">
</form>
</body>
</html>
----- onClick2.php ------
<?php printf(isset($aceptar)); ?>