|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi! everyone.... im doing my project and i need some help from u who knows VB.Net..
does anyone know how to valid8 err, validate an email ID...considering the @ and . ![]() i hope anyone can help me... As Soon AS Possible.... thanks and God's Speed... does any1 knows how to validate an EMAIL ID... considering the @ and . signs..... ![]() |
|
#2
|
||||
|
||||
|
Try using regular expressions...
"Email validator that adheres directly to the specification for email address naming. It allows for everything from ipaddress and country-code domains, to very rare characters in the username." ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$ Coutesy of Andy Smith at Regular Expression Library If you need help validating with regular expressions, refer to the article "Validate With Regular Expressions" from Visual Studio Magazine. |
|
#3
|
|||
|
|||
|
thanks a lot... i'll try it later...=p
|
|
#4
|
|||
|
|||
|
The drag and drop regular expression validator in VS.Net has an email validator built-in to it.
|
|
#5
|
|||
|
|||
|
uhmmm... my language that im using is .vb
err... im doing windows application and not a web application(.aspx)..... thnx anyway... i guess the one that was post up there used for aspx....? |
|
#6
|
|||
|
|||
|
Validating e-mail ID
Private Sub MyValidatingCode()
' Confirm there is text in the control. If TextBox1.Text.Length = 0 Then Throw New Exception("Email address is a required field") Else If Not Regex.IsMatch(TextBox1.Text, "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*") Then Throw New Exception("E-mail address must be valid e-mail address format." + ControlChars.Cr + "For example 'someone@microsoft.com'") End If End If End Sub Private Sub textBox1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating Try MyValidatingCode() Catch ex As Exception ' Cancel the event and select the text to be corrected by the user. e.Cancel = True TextBox1.Select(0, TextBox1.Text.Length) ' Set the ErrorProvider error with the text to display. Me.ErrorProvider1.SetError(TextBox1, ex.Message) End Try End Sub Private Sub textBox1_Validated(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles TextBox1.Validated ' If all conditions have been met, clear the error provider of errors. ErrorProvider1.SetError(TextBox1, "") End Sub |
|
#7
|
|||
|
|||
|
Quote:
can somebody tell me how to use builtin email validator ??? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > Pls help me to validate EMAIL ID..ASAP!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|