标签:
private void Testbox_TextChanged(object sender, TextChangedEventArgs e)
{
var textbox = (TextBox)sender;
if (!Regex.IsMatch(textbox.Text, "^\\d*\\.?\\d*$") && textbox.Text != "")
{
int pos = textbox.SelectionStart - 1;
textbox.Text = textbox.Text.Remove(pos, 1);
textbox.SelectionStart = pos;
}
}
只能输入字符和数组的正则表达式:"^[A-Za-z0-9]+$"
标签:
原文地址:http://www.cnblogs.com/wuwei928/p/5374287.html