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
Re: how to check if numbers and letters are entered in a textbox
Wrong Forum.
Try to ask it in Manageged C++/CLI Forum
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.
Re: how to check if numbers and letters are entered in a textbox
Quote:
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.
Re: how to check if numbers and letters are entered in a textbox
Quote:
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! :D And what if the character in question is a '0'? ;)
No, honestly: GCDEF's suggestion is the method of choice.