I have the following validation for the username:
if (empty($_POST["username"])) {
$nameErr = "Username:Escolha um username.";
} else {
$uname = test_input($_POST["username"]);
$v1 = 'ok';
if (!ereg("(^[a-zA-Z0-9]+([a-zA-Z\_0-9\.-]*))$", $_POST["username"])) {
$v1 = 'ko';
$nameErr = "Username:Somente letras e números.";
}
}
This way I can successfully validate a username that contains letters or numbers or if the field is blank. But how can I validate the number of characters?