C#怎样实现文本框只能输入只能输入0~99.99数字。
C#怎样实现文本框只能输入只能输入0~99.99数字。
------解决方案-------------------- <asp:TextBox ID= "txtFloat " runat= "server " />    
  <asp:RangeValidator ID= "rv " ControlToValidate= "Choice " MinimumValue= "0 " MaximumValue= "99.99 " ErrorMessage= "输入必须是0-99.99之间的数 " Type= "Double " Display= "dynamic " runat= "server ">  
  </asp:RangeValidator>
------解决方案--------------------((? <=\D)|^)\d{1,2}\.\d{0,}((?=\D)|$)
------解决方案--------------------^\d{0,2}\.?\d{0,2}$
------解决方案--------------------正则: 
 \d(\.\d+)?     
 ////////////////////////////////////////////// 
 MSN:bdbox@hotmail.com请给我一个与您交流的机会!
------解决方案--------------------string strSrc =  "99.9998 "; 
             Match res = Regex.Match(strSrc,@ "((? <=\D)|^)\d{1,2}\.\d{0,}((?=\D)|$) "); 
             if (res.Success) 
             { 
                 MessageBox.Show(res.Value); 
             }
------解决方案--------------------string strSrc =  "99.9998 "; 
             Match res = Regex.Match(strSrc,@ "^\d{1,2}(\.\d{0,})?$ "); 
             if (res.Success) 
             { 
                 //正确 
             }   
 文本框。那这样。
------解决方案--------------------private bool VaildNumber(string str) 
         { 
             string IsNumber = @ "^[0-9]*$ "; 
             Regex Reg = new Regex(IsNumber);   
             return Reg.IsMatch(str);   
         }   
        using System.Text.RegularExpressions;   
       判断你要传的文本框值 是不是 true  如果是False 则表示不全是数字
------解决方案--------------------楼上的还有点点问题: 
 ^\d{1,2}(\.\d{0,2})?$
------解决方案--------------------to :wuyazhe 
 要求小数点后2位...     
 PS:我刚写的正则有点问题
------解决方案--------------------string strSrc =  "99.9998 "; 
             Match res = Regex.Match(strSrc,@ "^\d{1,2}(\.\d{0,2})?$ "); 
             if (res.Success) 
             { 
                 //正确 
             }   
 2位