一直使用三楼的方法 比较简单

愛生活 && 愛編程
2007-06-19 15:37
2007-07-14 09:51
垃圾,给你们一个比较全的.
private bool panduan(string a)
{
return Regex.IsMatch(a, @"^\d*[.]?\d*$");
}
private void textBox4_Validating(object sender, CancelEventArgs e)
{
button1.Enabled = true;
bool a = panduan(textBox4.Text.Trim());
if (a == false || textBox4.Text==string.Empty)
{
e.Cancel = true;
errorProvider1.SetError(textBox4, "价格只能为数字,且不能为空,请正确输入");
}
else
{
e.Cancel = false;
errorProvider1.SetError(textBox4, "");
}
}
你的开始不能输入负号 并且整数开头可以有N个0出现
且存在“5.”这种数字
^[-]?(0|([1-9]\d*))(\.\d+)?$

2007-07-14 10:01
2007-07-14 11:31
2007-07-15 17:08
2007-07-16 15:43
2007-07-16 16:44
2007-07-16 17:05
2007-07-18 14:38
2007-07-19 21:23