I know there is a whole lot of questions regarding this very same issue, but I'm so stuck with it. I have a hard time getting what's wrong. I have tried many things from Google, with no luck. I am trying to have the validation errors showing next to their relevant input fields instead of just being displayed at the form top. The form is quite big so I'll just post a "sample" of it.
HTML form:
<form action="register.php" method="POST">
<table>
<th class="topLine">
<label for="form_login" >Login
</th>
<td>
<div class="form_input_bg">
<input type="text" name="username" value="" maxlength="16" size="16"/>
<?php echo $username;?>
</div>
</td>
</tr>
<tr>
<th class="topLine">Password
<p style="font-size:9px;">8-16 Character (only a-Z,0-9)</p>
</th>
<td>
<div class="form_input_bg">
<input type="password" name="pass" value="" maxlength="16" size="16"/>
</div>
</td>
</tr>
<tr>
and the PHP validation, it happens to be like this, still a sample of it (don't wanna hurt your eyes).
<?PHP
elseif(strlen($_POST['username']) < 5)
{
echo '<div class="message">Username must be longer than 4 characters
</div></div><p>
?>