Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CompareValidator control assistance

Reply
Thread Tools

CompareValidator control assistance

 
 
Groove
Guest
Posts: n/a
 
      08-16-2006
I have a form that has several fields which accept integers. These fields
are mileage fields so the value in the fields is easily in the hundreds of
thousands. Ex: 152,750. The form loads existing data and lets users update
it.

When the form loads the data, I format it in the field as a "number" to make
it easier to read like so:

decMileage = drItemData("TotalMileage")
txtMileage.Text = decMileage.ToString("n0")
This will turn 152750 into 152,750 in the field and makes it much easier to
read. To prevent the user from entering non-numeric characters, I have a
CompareValidator with these fields. It checks the data type and makes sure
it's an integer. The problem is the validator control doesn't like the
commas in the value and can't validate it. It will still trigger the
validator control.

<asp:TextBox ID="txtMileage" runat="server" Columns="12" ToolTip="Total
Milage" />

<asp:RangeValidator ID="MileageValidator" runat="server"
ControlToValidate="txtMileage" ErrorMessage="*Total Mileage must be numeric
and between 1 and 9999999." MaximumValue="9999999" MinimumValue="1"
SetFocusOnError="True" Type="Integer" >

So can I have both? Can I format it upon page load with the comma and STILL
allow the form to accept 999,999 as well as 999999?

asp.net 2/vb



Thanks!



--



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTypeCheck in comparevalidator control Chris Leffer ASP .Net 2 04-21-2009 11:58 AM
comparevalidator control interprets date in the wrong format VancouverMike ASP .Net 0 04-11-2008 12:26 AM
CompareValidator firing in Page_Load, validating empty control Eric Maia ASP .Net 2 11-18-2004 05:47 PM
Problem with CompareValidator control Andres Aguiar ASP .Net Web Controls 1 07-29-2004 01:51 AM
problem of CompareValidator control ( for check date) pc ASP .Net Web Controls 0 03-07-2004 03:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57