验证函数大集合(一)

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   "实数格式不正确 "; 
} 
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值