473,657 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple C# validation.

3 New Member
There was no way to post in the C# forum so I figured I had to post here.
I am having trouble with simple validation.
All I want to do is validate a text box so that if a number is entered, an error occurs.

I can check lengths and for nulls but I cant figure this one out.

I have tried using a char.IsDigit but that doesnt work, and apparently it isnt as simple as string.contains = 1,2,3 etc.

Im really stuck. Can anybody help me out?
May 3 '07 #1
3 7071
Ganon11
3,652 Recognized Expert Specialist
Do you need to produce an error if the entire string is a number? If there is a number inside the string?

For the first, you can loop through the text. If there is any character which is NOT numeric, then you are OK.

For the second, you can loop through the text. If there is any character which IS numeric, then you are NOT OK.
May 3 '07 #2
meripu1
3 New Member
I dont want to be able to type a number.
Could I put some validatin on the actual text box so that if a number is typed, it would not accept it?
May 3 '07 #3
Prasannaa
21 New Member
Hi ,

try this link
http://msdn2.microsoft .com/en-us/library/system.windows. forms.keyeventa rgs.aspx

Regards
Prasannaa
May 4 '07 #4

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

Similar topics

7
2966
by: r0adhog | last post by:
I have a very simple form: <html> <head> </head> <body> <% function ValForm() if len(document.form.newapp.all("AccessCode").Value) = 4 then document.form.newapp.submit()
51
8258
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct code? many thx!
2
8387
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when submitting the form to update the database. The server doesn't have the client side value any more. It seems to me that as I begin to write the client side javacript code for form validation and client side editing capabilities in order to save...
2
1644
by: SimonH | last post by:
Hi All, I'm having problems getting a custom validator to work. I'm hoping someone could perhaps notice what I've missed. I only want to provide a server side validation method. The problem is basically that the method that I've designated as the validation routine never gets called so I can't do anything about potentially duff data. I've declared the custom control as:
18
3026
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
8
1274
by: Abul Hasan | last post by:
Hello everyone, I have placed simple validation through ErrorProvider Class on my textBoxes to check whether ther r empty or not Error Provider Class check and catches the error but it doesn't stop saving the record. For instance if I click on any other button on the form it doesn't stop user from doing so. How can I stop or restrict user to stay in the textbox prebenting any other button or option to be clicked as long as there is a...
6
1406
by: aaryan | last post by:
hi guys, just want to know the answer to the following question: What types of data validation events are commonly seen in the client-side form validation? simple,it will be for many. but can you ppl help me out?
3
3097
by: Eric Lilja | last post by:
Hello, this is an xml-file with a nested DTD. It validates, test-1- with-dtd.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE persons > <persons> <person name="Eric Lilja" /> </persons>
2
1400
by: argylew | last post by:
This is simple, SO simple but I dont know how to do it!! I have 5 text boxes on one page (all contain numbers). The 5th box is the sum of the first four. I need to validate it so that the the value of the first 4 text boxes is either "0" or greater than 40 - the default of these is "0" so I thought a validation onChange() would help here??
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7354
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.