private void txtReceiverContact_TextChanged(object sender, EventArgs e)
{
if (System.Text.RegularExpressions.Regex.IsMatch(txtReceiverContact.Text, " ^ [0-9]"))
{
txtReceiverContact.Text = "";
}
}
private void txtReceiverContact_KeyPress(object sender, KeyPressEventArgs e)
{
string senderText = (sender as TextBox).Text;
string senderName = (sender as TextBox).Name;
int cursorPosition = (sender as TextBox).SelectionStart;
if (!char.IsControl(e.KeyChar)
&& !char.IsNumber(e.KeyChar))
{
e.Handled = true;
}
}
== When I will press any letter, message box will appear and show "Input Digit Only!"
== Digt will not be more than 11 (Eleven)