Non č detto. Una funzione JS la puoi inserire anche nel BODY
e, comunque, il tuo modulo č tutto in PHP, visto che

<form name="login" method="post" action="account.php">
<input type="hidden" name="action" value="login">

č html.

Potresti provare anche ad inserire la funzione js prima del tag <FORM...

Forse funziona.

Al limite quale che problema hai nell'inserire il tag head?