asp.net服务端使用正则表达式验证数据合法性.
根据如何用asp.net实现校验功能!一文进行了修改.对TextBox的值进行检测
文件:https://files.cnblogs.com/walkingboy/LangZi.Lib.rar
具体代码看如何用asp.net实现校验功能!:
简单使用:
ValidTextBox VT = new ValidTextBox();
VT.IsValidField(tb1,5,"闭填",false);
VT.IsValidDate(tb2,10,"日期",false);
VT.IsValidNumber(tb3,5,"数字",false);
VT.IsValidSSN(tb4,18,"身份证",false);
VT.IsValidUrl(tb5,30,"URL",false);
VT.IsValidZip(tb6,10,"ZIP",false);
if (!VT.IsValid)
{
//string js = "<script>alert('"+VT.ErrorMsg+"');</script>";
//Response.Write(js);
Label1.Text = VT.ErrorMsg;
}
VT.IsValidField(tb1,5,"闭填",false);
VT.IsValidDate(tb2,10,"日期",false);
VT.IsValidNumber(tb3,5,"数字",false);
VT.IsValidSSN(tb4,18,"身份证",false);
VT.IsValidUrl(tb5,30,"URL",false);
VT.IsValidZip(tb6,10,"ZIP",false);
if (!VT.IsValid)
{
//string js = "<script>alert('"+VT.ErrorMsg+"');</script>";
//Response.Write(js);
Label1.Text = VT.ErrorMsg;
}