.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification