So I am trying to put an error message for a textbox. The error message will show that only numbers are allowed after pressing a submit button. Are there any codes like that which will not affect the rest of my codes? I tried using the codes below but the error message does not show so an error occured.
if (System.Text.RegularExpressions.Regex.IsMatch(textbox1.Text, @"[^0-9],[^0-9]"))
{
MessageBox.Show("Only Numbers Allowed.");
textbox1.Text = textbox1.Text.Remove(textbox1.Text.Length - 1);
return;
}