void mobile_KeyUp(object sender, KeyEventArgs e)
{
Regex rg = new Regex("^[0-9]{1,11}$");
Regex rg1 = new Regex("\b");
if (!rg.IsMatch(mobile.Text) && !rg1.IsMatch(e.Key.ToString()))
{
if (mobile.Text.Length > 0)
{
mobile.Text = mobile.Text.Substring(0, mobile.Text.Length - 1);
mobile.SelectionStart = mobile.Text.Length;
}
else
{
mobile.Text = "";
}
}
}
silverlight 文本框只能输入数字,布布扣,bubuko.com
时间: 2024-10-11 00:42:29