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

How to limit input

ad
I want to limit the input of usr to 0..9 or a..z
How can I do that?
Dec 12 '06 #1
4 4261
"ad" <fl****@wfes.tcc.edu.twwrote in message
news:OT**************@TK2MSFTNGP06.phx.gbl...
>I want to limit the input of usr to 0..9 or a..z
How can I do that?
There are lots of ways. One would be to use a MaskedTextBox control.

Pete
Dec 12 '06 #2
Hi
If you are using winforms Masked Textbox would be appropriate choice.

Drag drop masked text box on to window form and set the mask property
to custom mask and put mask as AAAAAAAAAAAAAAAAAAA.

only pain point is you need to know the number of chars.

Hope this solves the issue at hand.

Thanks
-Srinivas.

ad wrote:
I want to limit the input of usr to 0..9 or a..z
How can I do that?
Dec 12 '06 #3
ad
Thanks,
How can I use regex expression?
"Duggi" <Du***************@gmail.com>
???????:11**********************@j44g2000cwa.googl egroups.com...
Hi
If you are using winforms Masked Textbox would be appropriate choice.

Drag drop masked text box on to window form and set the mask property
to custom mask and put mask as AAAAAAAAAAAAAAAAAAA.

only pain point is you need to know the number of chars.

Hope this solves the issue at hand.

Thanks
-Srinivas.

ad wrote:
>I want to limit the input of usr to 0..9 or a..z
How can I do that?

Dec 12 '06 #4
On Tue, 12 Dec 2006 14:02:47 +0800, ad wrote:
Thanks,
How can I use regex expression?

"Duggi" <Du***************@gmail.com>
???????:11**********************@j44g2000cwa.googl egroups.com...
>Hi
If you are using winforms Masked Textbox would be appropriate choice.

Drag drop masked text box on to window form and set the mask property
to custom mask and put mask as AAAAAAAAAAAAAAAAAAA.

only pain point is you need to know the number of chars.

Hope this solves the issue at hand.

Thanks
-Srinivas.

ad wrote:
>>I want to limit the input of usr to 0..9 or a..z
How can I do that?
Hey ad,

Here's a small program to do what you want

First, put this in the class imports

using System.Text.RegularExpressions;

Then run this
public static void Main()
{
//
// Get the input
//
string inputString="aA";
Console.WriteLine(IsValid(inputString));
Console.ReadLine();
}

//
// This function validates the input
//
static bool IsValid(string s){
//
// Create a regex
//
Regex r = new Regex(@"^[0-9a-z]*$");
//
// Check if the input matches
//
return r.IsMatch(s);
}
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: bigoxygen | last post by:
Hi... I have a form with almost 500 input text boxes. It seems like the $_POST variable's limit is 200 boxes, as print_r only gave me 200 elements. Has anyone else encountered this? It...
2
by: SAN CAZIANO | last post by:
how can I have on the right of an input field the number of the char that we can put on it (when it's length is changed this number must changed itself: perhaps onkeypress event)???
5
by: Jesper Rønn-Jensen | last post by:
I have a textarea that must be limited to 70 characters. No big deal -- at least so I thought. * Textarea must not exceed 70 characters * Exceeding content must be cut off * Must work on input by...
7
by: Danny | last post by:
HI I am trying to do this: array4 = split(astring,chr(9)) and it seems the array4 cannot be larger than 256 how can I get around this? I am trying to read in a file and parse it line by...
1
by: Luke Wu | last post by:
I have been using the getline function from K&R2 for simple character input. The prototype is int getline(char *s, int limit); /* returns 0 to signal EOF */ This function simply calls...
2
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've...
5
by: Jefferis NoSpamme | last post by:
Hi all, I'm trying to limit the file size of an image submission and I keep running into various problems. I've got most of it working, but I'm stumped and I have a basic question as to WHY this...
2
by: Terry | last post by:
Hi, i want to limit input in this textbox up to 2O characters, but i can input a unlimited amount of characters. How to limit that? <asp:TextBox ID="txtStreet" runat="server" Width="200px"...
6
by: howa | last post by:
Suppose the file is stored in "upload_tmp_dir ", so why I need to increase the memory limit? If I want to upload 100 MB, how large should I set? Thanks.
4
by: chemicalclothing | last post by:
Hi. I'm very new to Python, and so this is probably a pretty basic question, but I'm lost. I am looking to limit a float value to a number between 0 and 100 (the input is a percentage). I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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...

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.