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)

Amit GuptaRank #190 · 12.8K reputationPosted Apr 28, 2017, 6:36 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Apr 28, 2017, 8:51 PM EDT
Khaja MoizuddinRank #270 · 9.4K reputationPosted Apr 28, 2017, 9:21 AM EDT
Bryian TanRank #396 · 6.3K reputationPosted Apr 28, 2017, 6:15 AM EDT