我在输入的时候 首先要判断是否数字,
然后不能为0 因为输入0没意义 如果输入0.00(虽然符合格式但没意义)也不行
格式为 尺寸大小:decimal(8,3)精确到3为小数 例如9.123 不带小数也行 就为整数如100
订购数量 decimal(13,2) 精确到2为小数 例如100.12 不带小数也行 就为整数 如100
然后不能为0 因为输入0没意义 如果输入0.00(虽然符合格式但没意义)也不行
格式为 尺寸大小:decimal(8,3)精确到3为小数 例如9.123 不带小数也行 就为整数如100
订购数量 decimal(13,2) 精确到2为小数 例如100.12 不带小数也行 就为整数 如100
using System.Text.RegularExpressions;
public bool Match(string str)
{
Regex r = new Regex(@"(^[1-9]+\d*\.\d*[1-9]$)|(^0\.\d*[1-9]$)|^[1-9]\d*$|^0$");
return r.IsMatch(str);
}
精度3的:
(^[1-9]+\d*\.\d{1,2}[1-9]$)|(^0\.\d{1,2}[1-9]$)|^[1-9]\d{1,2}$|^0$
精度2的:
(^[1-9]+\d*\.\d{1}[1-9]$)|(^0\.\d{1}[1-9]$)|^[1-9]\d{1}$|^0$
{
System.Text.RegularExpressions.Regex reg1
= new System.Text.RegularExpressions.Regex(@"^[-]?\d+[.]?\d*$");
return reg1.IsMatch(str);
}