我的判断语句 if( (ec[i] != string.Empty) && (em[i] != string.Empty) 
&& (!Regex.IsMatch(ep[i],"[^\\d.]")) 
&& (!Regex.IsMatch(eb[i],"[^\\d.]"))
&& (decimal.Parse(eb[i]) > 0)
&& (decimal.Parse(ep[i]) > 0))
{

}
else
{
alertstr += "<FONT style='COLOR:#ff0000'>产品列表中第"+(i+1).ToString()+"行输入不正确!</FONT><br>";
result = false;
}主要是判断那个eb[i]必须为正整数   我这么写好象不对吧?  给个正确的来看看先~~  谢谢  晚上就要解决哟  明天要交差~~

解决方案 »

  1.   

    试试:Regex.IsMatch(eb[i], @"^\d+$")
      

  2.   

    如果不允许 "0","00" 之类,可以用 :Regex.IsMatch(eb[i], @"^\d+$") && !Regex.IsMatch(eb[i], @"^0+$")
      

  3.   

    不知道大家看懂了我那段代码的意思没有哟  (!Regex.IsMatch(eb[i],"[^\\d.]"))
    括号里有个“!”   哈哈
      

  4.   

    用 Regex.IsMatch(eb[i], @"^[1-9][0-9]*$") 试试。应该可以了。
      

  5.   

    “/”应用程序中的服务器错误。
    --------------------------------------------------------------------------------输入字符串的格式不正确。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
    [FormatException: 输入字符串的格式不正确。]
       System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +0
       SPLoan.WebForm1.SaveLoan(String isSumbit) +906
       SPLoan.WebForm1.Save(String isSumbit) +316
       SPLoan.WebForm1.ButtonSaveToDraft_Click(Object sender, EventArgs e) +30
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain() +1292 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:1.1.4322.2032; ASP.NET 版本:1.1.4322.2032
      

  6.   

    我输入的是1.05  错误啦
    表达式是  if( (ec[i] != string.Empty) && (em[i] != string.Empty) 
    && (!Regex.IsMatch(ep[i],"[^\\d.]")) 
    && (!Regex.IsMatch(eb[i],@"^[1-9][0-9]*$")) && (decimal.Parse(eb[i]) > 0)
    && (decimal.Parse(ep[i]) > 0))
      

  7.   

    你输入的 "1.05" 赋给哪个变量的?
    是不是 eb[i]="1.05" 啊???
      

  8.   

    不如用 onkeypress 只有keycode 码 在 0 和 9中 有效
      

  9.   

    我这种写法有什么不对吗?   (!Regex.IsMatch(eb[i],"[^\\d.]"))