473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

number text box in asp.net

11
Hi ,

Can any one help me to check for numbers alone, in a text box using C#?
Feb 19 '07 #1
4 1093
First of all, Add this to Top Line in .cs File,

using System.Text.RegularExpressions;


Now use The Following Function:

public static bool IsNumeric(string TextData)
{
string AllowChar = "[^0-9]";
if(Regex.IsMatch(TextData.Trim(),AllowChar))
return false;
else
return true;
}
Feb 19 '07 #2
mshiva
8
By using validators u can easily did this one without writing any code.
Feb 19 '07 #3
MariaJC
11
hi thanx for ur response. but i need alert if the user enters other than numbers.
how can i create an alert for the text box as soon as its focus is lost??

pls help
Feb 19 '07 #4
MariaJC
11
Hi i am not able to get the control id of txtNumber1
the value displayed is null
how can i access this controls id in javascript?

alert(document.getElementById("txtNumber1"));

please help
Feb 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: LRW | last post by:
I have an automated process which uploads a comma separated spreadsheet (csv) and inserts it into a database: $sql = "LOAD DATA INFILE '".$uploadfile."' INTO TABLE `tbl_tracking` FIELDS...
79
by: Klaus Bonadt | last post by:
In order to protect software from being copied without licence, I would like to use something like a key, which fits only to the current system. The serial number of the CPU or the current...
1
by: stuart | last post by:
I am trying to format a number in an unbound text field using the following format statement in the field's Exit event: txt11UnitWeight = Format(txt11UnitWeight, "00000.00") I want the number...
8
by: shumaker | last post by:
I see other posts where some say fields that will hold a number with leading zeros should be stored as text instead of numbers. This is very inefficient though, as a string of digit characters...
18
by: Vasilis Serghi | last post by:
Presently I define the number of lines to be expected in a file when defining the array size and the initialisation of this array. This works fine for now, but i'm sure that in the future this...
3
by: venu | last post by:
Hi, I have a different requirement and it is : I need to validate a phone number field. It may or may not be a US phone number. The constraints are : *********************** # It should...
0
by: Jean-François Michaud | last post by:
Hello all, I need to generate (SHEET X of Y) in titles for figures contained in a section (I already generate page A of B at the bottom right of every page in the document). Is there a way...
1
by: brad.goldberg | last post by:
2 Part question for you all, seems kinda tricky to me, but many of you are access gods compared to myself. Here's the deal... I have a label on my form called Run Number: Next to it I have a...
4
by: Orchid | last post by:
How can I change a Date datatype to a Number datatype? For example, I want a date 10/31/2006 to show 1031 as Number datatype. But I don't want it becomes 39021. What formula should I use? ...
19
Frinavale
by: Frinavale | last post by:
Filtering user input is extremely important for web programming. If input is left unfiltered users can input malicious code that can cripple your website. This article will explain how to make...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.