Ciao,
come richiami la funzione dal form?
Se la richiami dall'evento onsubmit dovresti restituire false per non far proseguire la sottomissione del form.
Potrebbe essere una cosa del genere:
	codice:
	<html>
<head>
<script>
function verifica(){
   var valoreimput = document.getElementById("num").value
   var query = '<%=rs.fields("numero")%>'
   if(valoreimput < query){
      alert('Errore');
      return false;
   }else{
      return true;
   }
}
</script>
</head>
<body>
<form action="submit.jsp" method="POST" onsubmit="return verifica()">
   <input type="submit" value="Invia" />
</form>
</body>
</html>
 
EDIT: scusa andrea, non avevo visto la tua risposta