|
-
November 16th, 2010, 04:22 PM
#1
how to check if numbers and letters are entered in a textbox
how do i check textboxes to see whether the user has entered letters, symbols and/or integers? My program requires the user to enter atleast one numeric value, if they don't enter atleast one number then an error message will show. i have tried the following but had no luck:
// checks password for letters
private: System::Boolean ValidateInput()
{
if (password != "0-9")
{
ShowMessage("password must contain atleast one numeric value (0-9).");
// clear text boxes
txtPassword->Text = "";
txtRePassword->Text = "";
}
}
any help will be appreciated thanks
Last edited by katy_price; November 16th, 2010 at 04:35 PM.
-
November 16th, 2010, 04:42 PM
#2
Re: how to check if numbers and letters are entered in a textbox
Wrong Forum.
Try to ask it in Manageged C++/CLI Forum
Victor Nijegorodov
-
November 16th, 2010, 04:46 PM
#3
Re: how to check if numbers and letters are entered in a textbox
Well, I imagine you would need to iterate through the letters and check each one until you found a number.
I'm not sure what your txtPassword variable is, but you can use atoi() to check a character to see if it's a number.
-
November 16th, 2010, 04:55 PM
#4
Re: how to check if numbers and letters are entered in a textbox
 Originally Posted by Ankheg
Well, I imagine you would need to iterate through the letters and check each one until you found a number.
I'm not sure what your txtPassword variable is, but you can use atoi() to check a character to see if it's a number.
You wouldn't want to use atoi. isdigit on the individual characters would be better. I imagine .net has something too, and the correct forum could provide the answer.
-
November 16th, 2010, 05:34 PM
#5
Re: how to check if numbers and letters are entered in a textbox
 Originally Posted by Ankheg
[...] you can use atoi() to check a character to see if it's a number.
A really creative application of that function! And what if the character in question is a '0'? 
No, honestly: GCDEF's suggestion is the method of choice.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|