VB.NET: Checking Email Address and Handphone number
I have 3 questions regarding checking handphone and email address
1) Say i enter helloy.yahoo.com to the textbox, how to check whether it is
a valid email address when i click on a button to send...
2) Same situation as the above, how to check whether the the user key in
the correct handphone number and length...
3) If the above two questions can be achieved, can it be possible to check
both email and handphone in one textbox when the user key in either
handphone or email...or is t better to spilt the textbox..
Thanks
Re: VB.NET: Checking Email Address and Handphone number
VB Code:
'inputEmail is the string that was input
Dim strRegex As String = "^([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})(\]?)$"
Dim re As Regex = New Regex(strRegex)
If re.IsMatch(inputEmail) Then
'continue
Else
MessageBox.Show("Invalid Email address!!")
End If
This example uses RegEx. Very useful for validations.
Re: VB.NET: Checking Email Address and Handphone number
Write a regular expression for your handphone verification too.
As for Q3, separate the two.
Re: VB.NET: Checking Email Address and Handphone number
how you see regular expression works...
Can you teach me how to see....
take your previous email as example..
I want to do it for handphone also..
Thanks
Re: VB.NET: Checking Email Address and Handphone number
Quote:
Originally Posted by toytoy
Can you teach me how to see....
<philosophical>It is you who must open your eyes and see, young one...</philosophical>
RegEx tutorial