Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to validate an email id which does not accept CAPITAL LETTER s. e.g adfff@gmail.com.
Posted
Comments
CHill60 21-Mar-14 6:24am    

1 solution

you can use something like this...


C#
function validateEmail(emailField){
        var reg = /^([a-z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;

        if (reg.test(emailField.value) == false)
        {
            alert('Invalid Email Address');
            return false;
        }

        return true;

}


if you need to omit the capital letters then just remove A-Z from your expression, and you need to allow both the letters capital as well as lower then use some thing like this, A-Za-z like above expression is modified to allow only lower letters, if we need to allow only capital then the expression is something like this...

Only Capital
^([A-Z0-9_\-\.]+)@[A-Z0-9-]+(\.[A-Z0-9-]+)*(\.[A-Z]{2,3})$


Both

^([A-Za-z0-9_\-\.]+)@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,3})$
 
Share this answer
 
Comments
Aravindba 21-Mar-14 6:34am    
5+
OPees 21-Mar-14 6:42am    
5+ :)

Tejas Vaishnav 21-Mar-14 6:44am    
Thanks,
Member 10684630 21-Mar-14 7:19am    
actually i have tried dis but it didnt work..
Tejas Vaishnav 21-Mar-14 8:32am    
I have tried to validate email like Axy@sbc.com and its not valid according to regex, because A is in capital and when i tried axy@sbc.com its validate.. so what you have tried to check, can you give me an example where you got issue, can you share that email id which is not validate using this regex..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900