Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validating email with apostrophe
Message
 
 
To
01/02/2016 14:08:52
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01630479
Message ID:
01630489
Views:
34
>>I have the following validation expression for an email text box. I need to allow an apostrophe to be in the email address. My understanding is that I need to add the apostrophe to the ValidationExpression ('). But I am not sure where in the following expression the apostrophe should be? Should it be in the first bracket, e.g. [-+.'] or some other place?
>>
>>
>>ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
>>
>
>If you want to consider more, I have the following:
>
>
>    Public Function Validate() As Boolean
>        Dim lnLocation As Integer = 0
>
>        ' Initialization
>        cEmail = Trim(cEmail)
>
>        ' The email cannot be blank
>        If cEmail.Length = 0 Then
>            cMessage = cEmailCannotBeBlank
>            Return False
>        End If
>
>        ' No dot
>        If InStr(cEmail, ".") = 0 Then
>            cMessage = cYouNeedToHaveAtLeastOneDotInTheEmail
>            Return False
>        End If
>
>        ' No @
>        If InStr(cEmail, "@") = 0 Then
>            cMessage = cYouNeedToHaveAtLeastOneAtSignInTheEmail
>            Return False
>        End If
>
>        ' We need to have at least 5 characters
>        If cEmail.Length < 5 Then
>            cMessage = cYouNeedToHaveAtFiveCharacterInTheEmail
>            Return False
>        End If
>
>        ' We can't accept an email starting with @
>        If Mid(cEmail, 1, 1) = "@" Then
>            cMessage = cYouCannotHaveAnEmailStartingWithAnAtSign
>            Return False
>        End If
>
>        ' The last character cannot be a dot
>        If Mid(cEmail, cEmail.Length, 1) = "." Then
>            cMessage = cTheLastCharacterOfYourEmailCannotBeADot
>            Return False
>        End If
>
>        ' If we have more than one @
>        If oApp.Occurs("@", cEmail) > 1 Then
>            cMessage = cYouCannotHaveMoreThanOneAtSignInTheEmail
>            Return False
>        End If
>
>        ' No space
>        If InStr(cEmail, " ") > 0 Then
>            cMessage = cYouCannotHaveASpaceInTheEmail
>            Return False
>        End If
>
>        ' No comma
>        If InStr(cEmail, ",") > 0 Then
>            cMessage = cYouCannotHaveACommaInTheEmail
>            Return False
>        End If
>
>        ' After the last dot, we can't have a digit
>        If Val(Mid(cEmail, oApp.At(".", cEmail, oApp.Occurs(".", cEmail)) + 1)) > 0 Then
>            cMessage = cAfterTheLastDot
>            Return False
>        End If
>
>        lnLocation = InStr(cEmail, "@")
>
>        ' We cannot have a dot immediately after the @
>        If Mid(cEmail, lnLocation + 1, 1) = "." Then
>            cMessage = cYouCannotHaveADotAfterAtSign
>            Return False
>        End If
>
>        lnLocation = InStr(cEmail, ";")
>
>        ' We cannot have a semi-colon
>        If lnLocation > 0 Then
>            cMessage = cYouCannotHaveASemiColonInTheEmail
>            Return False
>        End If
>
>        ' We cannot have a dot at the end
>        If Mid(cEmail, cEmail.Length, 1) = "." Then
>            cMessage = cYouCannotHaveADot
>            Return False
>        End If
>
>        ' We cannot have a dot before the @
>        If oApp.At(".@", cEmail) > 0 Then
>            cMessage = cYouCannotHaveADotBeforeAtSign
>            Return False
>        End If
>
>        ' If we have a <
>        If oApp.At("<", cEmail) > 0 Then
>            cMessage = cYouCannotHaveALessThanSign
>            Return False
>        End If
>
>        ' If we have a >
>        If oApp.At(">", cEmail) > 0 Then
>            cMessage = cYouCannotHaveAGreaterThanSign
>            Return False
>        End If
>
>        Return True
>    End Function
>
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform