public string IsFull(string Inputvalue)
{
if(Inputvalue== " ")
{
return "不能为空 ";
}
else
{
return " ";
}
}
public string IsInter(string Inputvalue)
{
/* 判断输入是否为整型*/
if(Inputvalue== " ")return " ";
string pattern = @ "^[1-9]+$ ";
Match m = Regex.Match(Inputvalue,pattern);
if(m.Success)
{
return " ";
}
else
{
return "整数格式不正确 ";
}
}
public string IsData(string Inputvalue)
{
/* 判断输入是否为日期型*/
if(Inputvalue== " ")return " ";
string pattern = @ "^(20|19)\d{2}(-|\/|年)((0[1-9])|[1-9]|(1[0-2]))(-|\/|月)((0[1-9])|[1-9]|([1-2][0-9])|(3[0-1])|(0[1-9]日)|[1-9]|([1-2][0-9]日)|(3[0-1]日))$ ";
Match m = Regex.Match(Inputvalue,pattern);
if(m.Success)
{
return " ";
}
else
{
return "日期格式不正确 ";
}
}
public string IsID(string Inputvalue)
{ /* 判断输入是否为身份证*/
if(Inputvalue== " ")return " ";
string pattern = @ "([0-9]{14}[x0-9]{1})|([0-9]{17}[x0-9]{1}) ";
Match m = Regex.Match(Inputvalue,pattern);
if(m.Success)
{
return " ";
}
else
{
return "身份证格式不正确 ";
}
}
public string IsPhotoNum(string Inputvalue)
{ /* 判断输入是否为电话号码*/
if(Inputvalue== " ")return " ";
string pattern = @ "^\d{3,4}\-\d{7,8}$ ";
Match m = Regex.Match(Inputvalue,pattern);
if(m.Success)
{
return " ";
}
else
{
//Response.Write( " <script> alert( '电话号码输入错误! '); </script> ");
return "电话号码格式不正确 ";
}
}
public string IsNumber(string Inputvalue)
{ /* 判断输入是否为实数*/
if(Inputvalue== " ")return " ";
string pattern = @ "^[0-9]\d*[.]?\d*$ ";
Match m = Regex.Match(Inputvalue,pattern);
if(m.Success)
{
return " ";
}
else
{
return "实数格式不正确 ";
}
}
验证函数大集合(一)
最新推荐文章于 2022-08-07 22:40:54 发布