Results 1 to 2 of 2

Thread: Check Email if gmail and valid password length

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2009
    Posts
    6

    Check Email if gmail and valid password length

    Check Email if gmail and valid password length.

    Screenshot:


    Code:
    Public Class Form1
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            checkemail(TextBox1.Text, TextBox2.Text)
        End Sub
    
        Private Shared Function checkemail(ByVal email As String, pass As String) As Boolean
            If isemailvalid(email) = True Then
                If isgmail(email) = True Then
                    If validpass(pass) = True Then
                        MsgBox("Valid gmail and valid password Length!")
                        ' Do valid processing here!
    
                    Else
                        MsgBox("Invalid Password Length!")
                    End If
                Else
                    MsgBox("Not a valid gmail account")
                End If
            Else
                MsgBox("Invalid Email")
            End If
        End Function
    
        Private Shared Function isemailvalid(ByVal email As String) As Boolean
            ' If the email matches the regular expression
            Dim Expression As New System.Text.RegularExpressions.Regex("\S+@\S+\.\S+")
            If Expression.IsMatch(email) Then
                Return True
            Else
                Return False
            End If
        End Function
    
        Private Shared Function isgmail(ByVal email As String) As Boolean
            If email.Contains("@gmail.com") = True Then
                Return True
            Else
                Return False
            End If
        End Function
    
        Private Shared Function validpass(ByVal pass As String) As Boolean
            If pass.Length >= 8 Then
                Return True
            Else
                Return False
            End If
        End Function
    End Class
    This code might be useful for validating email address.
    Last edited by Hack; May 14th, 2011 at 05:43 AM.

  2. #2
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Check Email if gmail and valid password length

    You should really perform more thourough validation if you want to post this in the CodeBank. If you don't know much about regular expressions, this thread contains one for validating e-mail addresses that is much more strict.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width