473,322 Members | 1,232 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,322 software developers and data experts.

Restrict user to enter numeric value in textbox

2
hi all
i would like to know how to restrict user from entering numeric value
ina textbox..using C#
if user try to enter text it shouldnt be allowed..
i tried errror provider..
but it doesnt met my requirement..
thanks in advance for ur valuable reply
let me know the best to do it

urs
SKS
Nov 10 '06 #1
5 13436
have u used any of the validators?
Nov 10 '06 #2
nmsreddi
366 256MB
hello

if you are familar with java script then its better choice to use (web application)

other wise you have write the code in codebehing using C# by using ASCII values verify the each key stroke value if the mach is success then do nothing

if the condition fails have a popup(if windows pplication)


try it out


regards

nmsreddi
Nov 13 '06 #3
Attiq
1
H!
To restrict user from different inputs you can use these fuctions:
IsDigit
IsHighSurrogate
IsLetter
IsLetterOrDigit
IsLower
IsLowSurrogate
IsNumber
IsPunctuation
IsSeparator
IsSurrogate
IsSurrogatePair
IsSymbol
IsUpper
IsWhiteSpace


private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (Char.IsDigit(e.KeyChar) )
{ MessageBox.Show("Bad Input");
e.Handled = true; ;
}
}
Mar 11 '08 #4
VijaySofist
107 100+
hi all
i would like to know how to restrict user from entering numeric value
ina textbox..using C#
if user try to enter text it shouldnt be allowed..
i tried errror provider..
but it doesnt met my requirement..
thanks in advance for ur valuable reply
let me know the best to do it

urs
SKS
Add the following code in the script side of your html text box control

Expand|Select|Wrap|Line Numbers
  1. onkeydown="if (window.event.keyCode > 47 && window.event.keyCode < 58){ return false; }"
All The Best
With Regards
Vijay. R
Apr 11 '08 #5
malav123
217 100+
Hi,
just write the following function in javascript for your requirement...
Expand|Select|Wrap|Line Numbers
  1. function noNumeric()
  2. {
  3.        if( !isNaN(yourtextbox.value))
  4.         {
  5.                    alert("Numerics not allowed");
  6.                    return false;
  7.           }
  8. }
  9.  
Apr 11 '08 #6

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

Similar topics

2
by: Sanka | last post by:
I want to restrict users entering non numeric characters in a text box How can I do this? If there is any code sample please answer or email I'll be very glad Thank you
2
by: sp | last post by:
Hello Everybody, How can I restrict the user entering non-numeric data in textbox control on server side using asp.net. Any Code sample or suggestions are appreciated. Thanks in advance sp
3
by: divaof_7 | last post by:
I've a textbox field, where user enters his name. I want to restrict him from entering double and singls inverted commas.What kind of function should i write.
2
by: colleen1980 | last post by:
There is a textbox and a drop down. Once user enters any value in the textbox he has to select the option from drop down otherwise the cursor will not allow to move anywhere else accept the drop...
1
by: =?Utf-8?B?Qw==?= | last post by:
I want to restrict the user entering nonalphanumeric keys using Javascript onKeypress. One exception is that I want to allow the user to enter spaces. How can I do this? Thanks in Advance.
5
by: Cylix | last post by:
I would like to let the client input numeric, "," and "-" in the textbox, all the other else charater will take no effect on the value of the textbox. How can I do so? Thanks a lot!
3
by: sasimca007 | last post by:
Hello friends, We have seen many textboxes, it is used as date,readonly,text etc... If we want to restrict the textbox with not to enter letters only numbers and one more...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
5
lotus18
by: lotus18 | last post by:
Hello World! I have a sample code here written in vb .net that restricts the textbox to accept only alpha, alphanumeric or numeric characters. Public Enum MyOption Alpha = 1 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.