CompareValidator control assistance

G

Groove

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!



--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top