I know this question will be closed because I studied many example of this but please see I think I am doing something different.
I coded my server side PHP email validation with this:
if (!filter_var($user_new_email, FILTER_VALIDATE_EMAIL)) {
$errors .="Email,";
$pass = false;
}
My client side email validation is:
function validateEmail(txtEmail){
var a = document.getElementById(txtEmail).value;
var filter = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{1,4}$/;
if(filter.test(a)){
return true;
}
else{
return false;
}
So in my client side if I enter only username@domain (without .com), it's valid. I don't want that.
I need the same validaton in both client and serverside. How to update my regular expression in JavaScript?