Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

EMAIL VALIDATION with regular expressions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marlon - 14 Jul 2005 21:55 GMT
How can modify this expression
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
to validate multiple email address separator by comma and/or semicolon

e.g. someone@somedomain.com;someone2@somedomain.com
Jim - 14 Jul 2005 22:42 GMT
Take yourself over to http://www.regexlib.com/

But you should probably heed the warning about email validation!?
http://regexadvice.com/blogs/dneimke/archive/2005/04/01/259.aspx

Jim

> How can modify this expression
> \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
>  to validate multiple email address separator by comma and/or semicolon
>
> e.g. someone@somedomain.com;someone2@somedomain.com
"Peter Huang" [MSFT] - 15 Jul 2005 06:29 GMT
Hi

I think you may try to split the string with ; first , and then validate
each one.
Regex.Split Method
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemTextRegularExpressionsRegexClassSplitTopic3.asp

Best regards,

Peter Huang
Microsoft Online Partner Support

Signature

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

raghavendras@tarangtech.com - 02 Aug 2005 08:37 GMT
Hi you can use the following script:

if( multiEmail() )
      document.PdfEmailForm.submit();

function multiEmail()
    {
       var str=document.PdfEmailForm.to.value;
        var email = str.split(',');
        for (var i = 0; i < email.length; i++)
            {               
                if(!checkemail(email[i]))
                {
                                 alert('one or more  
                                  email addresses are not
                                  valied');   
                                return false;   
                                                    }
           
            }
                return true;   
    }

    function checkemail(email)
    {
        var str=document.PdfEmailForm.from.value;
       
        var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

        if (filter.test(str) && filter.test(email))
            return (true)
        else           
            return(false)   
   
    }   

where :

document.PdfEmailForm.to.value - E-mail ids what we enter in TO field.

document.PdfEmailForm.from.value - E-mail ids what we enter in TO field.
Alvin Bruney [Microsoft MVP] - 02 Aug 2005 18:08 GMT
another good place for regex stuff is regexlib.com

Signature

Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc, Amazon, B&H etc
-------------------------------------------------------------------------------

> Hi you can use the following script:
>
[quoted text clipped - 43 lines]
> Comprehensive, categorised, searchable collection of links to ASP &
> ASP.NET resources...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.