
1.首先在项目中添加必备js与css

2.代码中添加引用(必备引用)
script> script>
3.
中要验证的标签(做一些常用的演示)| 身份证(正则表达式库): | ||
| 身份证(外部函数): | ||
| 整数: | ||
| 正整数: | ||
| 负整数: | ||
| 数字: | ||
| 正数(正整数 + 0): | ||
| 负数(负整数 + 0): | ||
| 浮点数: | ||
| 正浮点数: | ||
| 负浮点数: | ||
| 非负浮点数(正浮点数 + 0): | ||
| 非正浮点数(负浮点数 + 0): | ||
| 颜色: | ||
| 你的EMAIL: | ||
| 手机: | ||
| 邮编: | ||
| 非空: | ||
| 图片: | ||
| 压缩文件: | ||
| ip4: | ||
| QQ号码: | ||
| 国内电话: | ||
| 用户名: | ||
| 字母: | ||
| 大写字母: | ||
| 小写字母: | ||
| 身份证: |
4.中的代码
5.效果图:

6.添加修改说明:
ajax验证用户是否存在
js代码 (html中一定要设置name值,否则动态是获取不到值的)
一般处理程序代码
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
#region 判断用户是否被注册过
string returnStr = "";
//这里其实是context.Request.QueryString根据name获取的值 一定要设置空间的name值
if (context.Request["userName"] != null && context.Request["userName"].ToString().Length > 0)
{
if (isExist(context.Request["userName"].ToString()))
{
returnStr = "false";
}
else
{
returnStr = "0";
}
}
else
{
returnStr = "null";
}
context.Response.Write(returnStr);
context.Response.End();
#endregion
}
#region 判断用户是否被注册过
public bool isExist(string userName)
{
Snet.BLL.UserAccount bll = new BLL.UserAccount();
return bll.Exists(userName);
}
#endregion
