I need to validate the value of an e-mail input. I have this code but it doesn't work. Could you help me please?
HTML
<input type="text" name="mail" class="mail" />
<button class="validate">VALIDATE</button>
JQUERY
$(document).ready(function(){
var setMail = $(".mail").val();
var mailVal = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
$(".validate").click(function(){
if (mailVal == setMail) {
alert("GOOD!");
}
else{
alert("WRONG!");
}
});
});