As requested in the comment "You would know how to disable the form button when the message appears?" in the response of Damon Dudek
,
and for the reasons set out in my reply "Why is it a contact form, so if the customer enters a wrong email and it still appears he can still click to send and send the message by a non-existent email, disabling the button when he has an invalid email he could not send!"
it is not necessary to disable the form button when the message appears, just put the validation in it too!!
Metodo Blur no input id='email'
and click on button type='submit'
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validate() {
$("#result").text("");
var email = $("#email").val();
if (validateEmail(email)) {
//$("#result").text(email + " é valido :)");
//$("#result").css("color", "green");
return true;
} else {
$("#result").text(email + " não é válido :(");
$("#result").css("color", "red");
return false;
}
}
$(".validate").bind("blur", validate);
$("#validate").bind("click", validate);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="/unanswered">
<p>email:</p>
<input id='email' class='validate'>
<button type='submit' id='validate'>Submit!</button>
</form>
<h2 id='result'></h2>
Input type="email" is not supported by IE9 and earlier and Safari.
Apple Safari ranks second to most used browsers, with 25.4 percent Source
And here another statistic no less negligible for Safari Source
I already use this in my input, but when I type other things than email and give "Submit" it returns the values, or in case it would be, if I type other values in the email field, it will save those values thinking it is email?
– Gustavo Souza
Yes it will, normal, who manages these suggestions is the user himself.
– Damon Dudek
Oh yes, thank you, I got it here! Would you know how to disable the form button when the message appears? I will update my question with the fields.
– Gustavo Souza