Puoi fare cosi....
codice:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function convalida() {
ok = true;
if (document.getElementById('nome').value == "") {
alert('Nome obbligatorio');
ok = false;
}
if (document.getElementById('cognome').value == "") {
alert('Cognome obbligatorio');
ok = false;
}
return ok;
}
//-->
</script>
<title>Untitled</title>
</head>
<body>
<form action="mia_pagina.php" method="post" onsubmit="return convalida()">
Nome <input type="text" id="nome" name="nome">
Cognome <input type="text" id="cognome" name="cognome">
<input type="submit" value="Invia">
</form>
</body>
</html>