473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

RegularExpressionValidator in codebehind

dim value as string = "noemail"
Dim emailc As New RegularExpressionValidator
emailcc.ControlToValidate = value
emailcc.ValidationExpression = "^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$"
Dim x As String = emailc.IsValid

why it gives me "true"?
where is the mistake?

grazie
franz
italy
______________
Franz
www.ewave.it/franz_photos

- La fama degli eroi spetta un quarto alla loro audacia; due
quarti alla sorte: e l'altro quarto ai loro delitti. -- Ugo Foscolo
Nov 18 '05 #1
3 2305
Hi,
The default value for IsValid is true. The actual value will be available
only after you called the Validate method on the validator control.
Also, the ControlToValidate should be the ID of the server control to be
validated. Not the string value you want to validate.

"-=franz=-" <ma**************@libero.it> wrote in message
news:2G*********************@twister2.libero.it...
dim value as string = "noemail"
Dim emailc As New RegularExpressionValidator
emailcc.ControlToValidate = value
emailcc.ValidationExpression = "^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$"
Dim x As String = emailc.IsValid

why it gives me "true"?
where is the mistake?

grazie
franz
italy
______________
Franz
www.ewave.it/franz_photos

- La fama degli eroi spetta un quarto alla loro audacia; due
quarti alla sorte: e l'altro quarto ai loro delitti. -- Ugo Foscolo

Nov 18 '05 #2
Indeed,
To do what you want to do, look at the
System.Text.RegularExpressions.Regex.IsMatch() shared method.

Karl
"Shiva" <sh******@online.excite.com> wrote in message
news:ut*************@TK2MSFTNGP12.phx.gbl...
Hi,
The default value for IsValid is true. The actual value will be available
only after you called the Validate method on the validator control.
Also, the ControlToValidate should be the ID of the server control to be
validated. Not the string value you want to validate.

"-=franz=-" <ma**************@libero.it> wrote in message
news:2G*********************@twister2.libero.it...
dim value as string = "noemail"
Dim emailc As New RegularExpressionValidator
emailcc.ControlToValidate = value
emailcc.ValidationExpression = "^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$"
Dim x As String = emailc.IsValid

why it gives me "true"?
where is the mistake?

grazie
franz
italy
______________
Franz
www.ewave.it/franz_photos

- La fama degli eroi spetta un quarto alla loro audacia; due
quarti alla sorte: e l'altro quarto ai loro delitti. -- Ugo Foscolo

Nov 18 '05 #3
thankyou guys!
ive done!
i was using a wrong class
at the end this was the correct one:

Dim regex As New
System.Text.RegularExpressions.Regex("^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$")

Dim match As System.Text.RegularExpressions.Match

match = regex.Match(ExistingEmail)

If Not match.Success Then

MsgErrore = MsgErrore & "Not correct email!<br>"

End If
______________
Franz
www.ewave.it/franz_photos

- La fama degli eroi spetta un quarto alla loro audacia; due
quarti alla sorte: e l'altro quarto ai loro delitti. -- Ugo Foscolo

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> ha scritto
nel messaggio news:eY*************@TK2MSFTNGP12.phx.gbl...
Indeed,
To do what you want to do, look at the
System.Text.RegularExpressions.Regex.IsMatch() shared method.

Karl
"Shiva" <sh******@online.excite.com> wrote in message
news:ut*************@TK2MSFTNGP12.phx.gbl...
Hi,
The default value for IsValid is true. The actual value will be available only after you called the Validate method on the validator control.
Also, the ControlToValidate should be the ID of the server control to be
validated. Not the string value you want to validate.

"-=franz=-" <ma**************@libero.it> wrote in message
news:2G*********************@twister2.libero.it...
dim value as string = "noemail"
Dim emailc As New RegularExpressionValidator
emailcc.ControlToValidate = value
emailcc.ValidationExpression = "^[\w-\.]+@([\w-]+\.)+[\w-]{2,3}$"
Dim x As String = emailc.IsValid

why it gives me "true"?
where is the mistake?

grazie
franz
italy
______________
Franz
www.ewave.it/franz_photos

- La fama degli eroi spetta un quarto alla loro audacia; due
quarti alla sorte: e l'altro quarto ai loro delitti. -- Ugo Foscolo


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andy Eshtry | last post by:
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox. EIN must be (for...
3
by: Ricardo Corsi P. Cesar | last post by:
Hi, i looking for example in asp.net (VB) to make the RegularExpressionValidator in runtime in my code behind. I found some similars codes, but nothing in VB.. thanks!
3
by: DC | last post by:
I have this snippet: <tr> <td align="left">E-mail</td> <td> <asp:TextBox id="txtEmail" runat="server" MaxLength="100"></asp:TextBox>&nbsp; <asp:RegularExpressionValidator id="revEmail"...
0
by: Matt Morris | last post by:
Hello: I have a RegularExpressionValidator control attached to a TextBox. I have the ValidationExpression property set to a very simple validation expression (\w+). The validation always fails...
3
by: tshad | last post by:
I have a RegularExpressionValidator that doesn't seem to work correctly if you don't enter anything. In the following, it works correctly if you have at least 1 character. If you just enter...
1
by: franz | last post by:
does anybody tell me why it doesn't works?? in any case gg beame true thanks franz Dim y As RegularExpressionValidator = New RegularExpressionValidator y.ValidationExpression =...
0
by: Vikram | last post by:
I am using regex class in codebehind to validate some control's text. But for checking , postback is done.I want to avoid postback and check the same exprseeion using regularexpressionvalidator. I...
1
by: John Yopp | last post by:
I'm trying to use a asp:RegularExpressionValidator to validate the strength of a password. When I test the regular expression with Regex.IsMatch, it works perfectly. However, when used within a...
4
by: =?Utf-8?B?Y3VyaW91cw==?= | last post by:
I am using a RegularExpressionValidator to validate a TextBox. I use "^?+(\.*)?$" to check for a real number. The control works fine as long as the user enters something in the TextBox; it does not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.