Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Email address validation

Email address validation

Scheduled Pinned Locked Moved Visual Basic
csharpjavascriptquestion
9 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz

    C S H 3 Replies Last reply
    0
    • R Rajiya

      Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      javascript has regex, so does .NET.  Just use a regular expression.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      A 1 Reply Last reply
      0
      • R Rajiya

        Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz

        S Offline
        S Offline
        Sachin Pimpale
        wrote on last edited by
        #3

        hi that is the code in JS switch case in acse of more validating fields u can add here check that if any prob kindly notify var mEmailAddress = ''; cInvalidEmailAddress = "Invalid email address in " cInvalidEmailAddress = "Invalid email address in " switch(cType) { case 'email' : var cVal; cVal=checkRequired(obj); if(cVal!=1 && cVal!=2) { mReqdFields = mReqdFields + cVal + '\n'; } else if(cVal==2) { if(!validateEmail(obj)) mEmailAddress = mEmailAddress + obj.caption + '\n'; } break; } if (mEmailAddress != '') ErrStr = ErrStr + cInvalidEmailAddress + mEmailAddress + '\n';

        SP -- Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.

        R 1 Reply Last reply
        0
        • C Christian Graus

          javascript has regex, so does .NET.  Just use a regular expression.

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          A Offline
          A Offline
          amaneet
          wrote on last edited by
          #4

          Sir, if u please send some code to validate the email address in the textbox (Window appliction). Thanks and Regards Pankaj

          1 Reply Last reply
          0
          • S Sachin Pimpale

            hi that is the code in JS switch case in acse of more validating fields u can add here check that if any prob kindly notify var mEmailAddress = ''; cInvalidEmailAddress = "Invalid email address in " cInvalidEmailAddress = "Invalid email address in " switch(cType) { case 'email' : var cVal; cVal=checkRequired(obj); if(cVal!=1 && cVal!=2) { mReqdFields = mReqdFields + cVal + '\n'; } else if(cVal==2) { if(!validateEmail(obj)) mEmailAddress = mEmailAddress + obj.caption + '\n'; } break; } if (mEmailAddress != '') ErrStr = ErrStr + cInvalidEmailAddress + mEmailAddress + '\n';

            SP -- Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.

            R Offline
            R Offline
            Rajiya
            wrote on last edited by
            #5

            Hi, I dont want to use javascript coz it is not a web application. Since it is a windows application i want to find a code which will validate the characters entered using ASCII codes. Waiting for ur reply. Thanks Riz

            D 1 Reply Last reply
            0
            • R Rajiya

              Hi, I dont want to use javascript coz it is not a web application. Since it is a windows application i want to find a code which will validate the characters entered using ASCII codes. Waiting for ur reply. Thanks Riz

              D Offline
              D Offline
              Dave Sexton
              wrote on last edited by
              #6

              This should do it :)

              Function IsValidEmail(strIn As String) As Boolean
              ' Return true if strIn is in valid e-mail format.
              Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
              End Function

              God bless msdn...

              R T 2 Replies Last reply
              0
              • D Dave Sexton

                This should do it :)

                Function IsValidEmail(strIn As String) As Boolean
                ' Return true if strIn is in valid e-mail format.
                Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
                End Function

                God bless msdn...

                R Offline
                R Offline
                Rajiya
                wrote on last edited by
                #7

                thanks a lot for ur solution

                1 Reply Last reply
                0
                • D Dave Sexton

                  This should do it :)

                  Function IsValidEmail(strIn As String) As Boolean
                  ' Return true if strIn is in valid e-mail format.
                  Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
                  End Function

                  God bless msdn...

                  T Offline
                  T Offline
                  the bombardier
                  wrote on last edited by
                  #8

                  @kulazfuk thanks that helped me too..

                  1 Reply Last reply
                  0
                  • R Rajiya

                    Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz

                    H Offline
                    H Offline
                    Hendrick
                    wrote on last edited by
                    #9

                    Hi, If have this solution in VB.NET. So it wil be helpfull for you. Regards Public Shared Function ValidEmailAddress(ByVal emailAddress As String, ByRef errorMessage As String, ByVal Textbox As System.Windows.Forms.TextBox) As Boolean ' Confirm there is text in the control. If Textbox.Text.Length = 0 Then Return True else errorMessage = "E-mail address is required." Return False End If ' Confirm that there is an "@" and a "." in the e-mail address, and in the correct order. If emailAddress.IndexOf("@") > -1 Then If (emailAddress.IndexOf(".", emailAddress.IndexOf("@")) > emailAddress.IndexOf("@")) Then errorMessage = "" Return True End If End If errorMessage = "E-mail address must be valid e-mail address format." + ControlChars.Cr + _ "For example 'someone@example.com' " Return False End Function Hi, If have this solution in VB.NET. So it wil be helpfull for you. Regards H.w. Hendrick, Netherlands

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups