how to validate number insert to a textbox field?

Posted on 2004-08-31
Last Modified: 2010-04-15
I have a textbox in a form where I need to enter the number of users. I need to make sure the person enters a number on that field. How can I validate that field?
<td class="NavyBold">Number of Users
(if multiple users):</td>
<td><asp:textbox id="txtusernumber" Runat="server" Width="50Px" MaxLength="4"></asp:textbox></td>
Question by:devweez
  • 2

Accepted Solution

msdixon earned 125 total points
ID: 11945781
add this to your page. it should point you in the right direction:

<asp:comparevalidator id="CompareValidator1" style="Z-INDEX: 104; LEFT: 136px; POSITION: absolute; TOP: 32px"
            runat="server" errormessage="Oops" type="Integer" controltovalidate="txtusernumber" valuetocompare="0"

Author Comment

ID: 11948312
Worked like a charm! thank you for the quick turn around on your answer. really helped!

Expert Comment

ID: 11948422
no problem

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now