What I need to do is when the email is not valid because of the alert in javascript I wanted to show a message over the form in question that showed that the email was invalid!
HTML CODE
<input type="email" class="form-control" name="email" id="email"
placeholder="Email" data-rule="email" data-msg="Introduza um email
válido"REQUIRED />
<div class="validation"></div>
</div>
PHP VALIDATION
if(isset($_POST["contact"]))
{
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$novocontacto = "insert into contacto(nomecompleto, email, assunto,
mensagem) VALUES ('$nomecomp', '$email', '$assunto' , '$mensagem')";
$novocontacto_run = mysqli_query($conn,$novocontacto);
echo
'<script type="text/javascript">alert("Mensagem enviada com sucesso!")
</script>';
}
else
{
echo '<script type="text/javascript">alert("Email inválido")</script>';
}
}