Search:
Namespaces
Discussions
.NET v1.1
Feedback
Validation
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngregexp' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Giovani B. Cardoso
-- Moved from [aspngarchitecture] to [aspngregexp] by G. Andrew Duthie (Moderator) <
Click here to reveal e-mail address
> --I am trying to validade a field that accepts only numeric characteres.If I usea
RegularExpressionValidator
with the property"ValidationExpression=[0-9]",it permits to insert only one numeric character (if I insert more thanone, the validationAccuses error).Is there any other kind of ValidationExpression?Giovani.
Reply to this message...
Wayne King
Put a plus sign after it, which means "one or more":
ValidationExpression=3D"[0-9]+"
or, a more concise form:
ValidationExpression=3D"\d+"
-----Original Message-----
From: Giovani B. Cardoso [mailto:
Click here to reveal e-mail address
]
Sent: Tuesday, December 04, 2001 10:34 AM
To: aspngregexp
Subject: [aspngregexp] Validation
-- Moved from [aspngarchitecture] to [aspngregexp] by G. Andrew Duthie =
(Moderator) <
Click here to reveal e-mail address
> --
I am trying to validade a field that accepts only numeric characteres.
If I use
a
RegularExpressionValidator
with the property
"ValidationExpression=3D[0-9]",
it permits to insert only one numeric character (if I insert more than
one, the validation
Accuses error).
Is there any other kind of ValidationExpression?
Giovani.
| [aspngregexp] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/asplists/aspngregexp.asp
=3D JOIN/QUIT
|
http://www.asplists.com/search
=3D SEARCH Archives
Reply to this message...
Aruna T
(Type your message here)
Hi,
I got struggled while implementing regular expression validator in asp.net. The below is my statement, Which i had given.
The below validation expression accepts "0" in the textbox.
If I enter only one digit that is "0" that should throw error message.
Can you suggest me how to do that.
<asp:RegularExpressionValidator Runat="server" ID="rxvMorDose" ControlToValidate="txtMorDose" ErrorMessage="Morning Dose must be Numeric" ValidationExpression="([0-9]+)|(-)">*</asp:RegularExpressionValidator>
--------------------------------
From: Aruna T
Reply to this message...
Scott Watermasysk (VIP)
Yes there is a better solution:
CompareValidator
<asp:CompareValidator runat = "Server" Type = "Integer" Operator =
"DataTypeCheck" ControlToValidate = "NumericTextField" Display = "Dynamic"
ErrorMessage = "Not a valid Number" CssClass = "errormessage" />
In addition, if you were stuck on using the
RegularExpressionValidator
, try
using : ^\d*$
HTH,
Scott
-----Original Message-----
From: Giovani B. Cardoso [mailto:
Click here to reveal e-mail address
]
Sent: Tuesday, December 04, 2001 1:34 PM
To: aspngregexp
Subject: [aspngregexp] Validation
-- Moved from [aspngarchitecture] to [aspngregexp] by G. Andrew Duthie
(Moderator) <
Click here to reveal e-mail address
> --
I am trying to validade a field that accepts only numeric characteres.
If I use
a
RegularExpressionValidator
with the property
"ValidationExpression=[0-9]",
it permits to insert only one numeric character (if I insert more than
one, the validation
Accuses error).
Is there any other kind of ValidationExpression?
Giovani.
| [aspngregexp] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngregexp.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Jason Salas
Hi Giovani,
You could try the following...a regular expression which assume 5 numeric
characters, then 4, then 5 again..something like: 12345-1234-12345
[0-9]{5} - [0-9]{4} - [0-9]{5}
...your ASP.NET validation control would then be:
<asp:RegularExpressionValidator
ControlToValidate="YOURCONTROLNAMEHERE"
ValidationExpression="[0-9]{5}-[0-9]{4}-[0-9]{5}"
Display="Dynamic"
ErrorMessage="You have not entered the data in the proper format!"
runat="server"
/>
<asp:CompareValidator
Type="Integer"
Operator="DataTypeCheck"
ControlToValidate = "YOURCONTROLNAMEHERE"
Display = "Dynamic"
ErrorMessage = "You did not enter a numeric value!"
runat="server"
/>
I combined this with /NET's CompreValidator, to ensure that the value is
numeric. For others, you can try the online Regular Expression Library at:
www.regexplib.com
HTH,
Jason
----- Original Message -----
From: "Giovani B. Cardoso" <
Click here to reveal e-mail address
>
To: "aspngregexp" <
Click here to reveal e-mail address
>
Sent: Wednesday, December 05, 2001 4:34 AM
Subject: [aspngregexp] Validation
> -- Moved from [aspngarchitecture] to [aspngregexp] by G. Andrew Duthie
(Moderator) <
Click here to reveal e-mail address
> --
[Original message clipped]
Reply to this message...
System.Web.UI.MobileControls.CompareValidator
System.Web.UI.MobileControls.RegularExpressionValidator
System.Web.UI.WebControls.CompareValidator
System.Web.UI.WebControls.RegularExpressionValidator
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com