刚懂一点正则式,写了个最麻烦的,还有,楼主最大的数只有3位,呵呵!我测了一下,符合楼主要求。public bool Isvalid(string inStr)
{
Regex reg = new Regex(@"^\d$|^[1-9]\d{1}$|^1[0-2][0-7]$");
Match mh = reg.Match(inStr);
if(mh.Success)
{
return true;
}
else
{
Response.Write("<script>alert('请输入0-127之间的数字')</script>");
return false;
}
}