I need to validate a password entry on a textbox, I have a few demands to fullfill in order to allow the user profile to be created and one of them is to refuse registration if the password contains anything else different than numbers and the alphabet letters the system needs to deny the entry, everything I tried seems to fail. Here is where I'm standing right now:
private void BUT_Signup_Click(object sender, EventArgs e)
{
string allowedchar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
if (!(TXT_NewPassword.Text.ToString().Contains(allowedchar)))
MessageBox.Show("No special characters on the password are allowed");