I'm using the following lines of JavaScript to validate an input as a valid email address:
// Check for a valid email address
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = $('#formRegister-emailAddress').val();
if(reg.test(address) == false) {
// Validation Failed
alert('Please enter a valid email address.');
}
This is working fantastic for most emails but it doesn't support wildcards like [email protected] but does support [email protected]
Any regex experts know if the regex used above can be updated to safely support wildcards?
Thanks