I am working on email validation for a asp.net server control.
Below are the sample emails system should allow -
test@domain.com
test@domain.subdomain.com
v-test@domain.com
v-test@domain.subdomain.com
Can anyone please tell me how to write a regular expression for the above email validation.
Here is my code working correctly for simple emails like test@domain.com
etc
var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/
var EmailmatchArray = UserEmail.match(emailPat);
if (EmailmatchArray == null) {
document.getElementById('<%=lblEmailErrorCtrl.ClientID%>').innerText = "Invalid email address";
return false;
}