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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

12 Experts available now in Live!

Get 1:1 Help Now