Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in .NET only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
Forum
Topic
.NET
number text box in asp.net
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
MariaJC
New Member
Join Date:
Feb 2007
Posts:
11
#1
number text box in asp.net
Feb 19 '07, 05:36 AM
Hi ,
Can any one help me to check for numbers alone, in a text box using C#?
Hari Narayan Sharma
New Member
Join Date:
Feb 2007
Posts:
7
#2
Feb 19 '07, 06:55 AM
First of all, Add this to Top Line in .cs File,
using System.Text.Reg ularExpressions ;
Now use The Following Function:
public static bool IsNumeric(strin g TextData)
{
string AllowChar = "[^0-9]";
if(Regex.IsMatc h(TextData.Trim (),AllowChar))
return false;
else
return true;
}
Comment
Post
Cancel
mshiva
New Member
Join Date:
Feb 2007
Posts:
8
#3
Feb 19 '07, 08:09 AM
By using validators u can easily did this one without writing any code.
Comment
Post
Cancel
MariaJC
New Member
Join Date:
Feb 2007
Posts:
11
#4
Feb 19 '07, 09:10 AM
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
Comment
Post
Cancel
MariaJC
New Member
Join Date:
Feb 2007
Posts:
11
#5
Feb 19 '07, 11:56 AM
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
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment