I have this sample:
CODE HTML:
<input type="text" name="email" class="email" placeholder="Your email address">
CODE JS:
$(document).ready(function ($) {
function validateEmail(email) {
var re = /\S+@\S+\.\S+/;
return re.test(email);
}
var email = $(".email").val();
if (validateEmail(email)) {
alert("correct format");
}else{
alert("icorrect format");
}
});
Code validation above does not work properly.
Can you tell me please what is the problem? Any data is entered in the input does not check properly
Thanks in advance!