基于AJAX的表单验证--clanY’sBlog
来源:互联网 发布:怡合达选型软件下载 编辑:程序博客网 时间:2024/05/21 13:26
导读:
AJAX with ASP: Form Validation
本文转自
http://www.51city.cn/blog/user1/11/archives/2006/4129.shtml
新用户中心的用户注册将采用无刷新操作,借鉴一下方案。
基于 AJAX 表单验证
validate.html
validate.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Session.CodePage=65001
Response.charset = "UTF-8"
If request("Type")="submit" Then
response.write request.form("txtUsername")
response.write "注册成功"
Else
fieldID=request("fieldID")
inputValue=request("inputValue")
result=""
If inputValue&"" = "" Then
Select Case fieldID
Case "txtUsername"
result="用户名不能为空!"
Case "selGender"
result="性别不能为空!"
Case "txtEmail"
result="邮箱不能为空!"
Case "txtPhone"
result="电话不能为空!"
End Select
Else
Select Case fieldID
Case "txtUsername"
result=Validate(inputValue,"^[/u0391-/uFFE5]+$","姓名必须为中文")
Case "txtEmail"
result=Validate(inputValue,"^/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*$","非法的电子邮件格式")
Case "txtPhone"
result=Validate(inputValue,"^((/(/d{2,3}/))|(/d{3}/-))?(/(0/d{2,3}/)|0/d{2,3}-)?[1-9]/d{6,7}(/-/d{1,4})?$","电话号码输入有误")
End Select
End If
response.write result
End If
Function Validate(v,p,e)
Dim objRegExp, strResult
strResult=""
Set objRegExp = New RegExp
With objRegExp
.Global = False
.IgnoreCase = True
.Pattern = p
End With
If objRegExp.Test(v) = False Then
strResult = e
Set objRegExp = Nothing
End If
Validate = strResult
End Function
%>
<%
Session.CodePage=65001
Response.charset = "UTF-8"
If request("Type")="submit" Then
response.write request.form("txtUsername")
response.write "注册成功"
Else
fieldID=request("fieldID")
inputValue=request("inputValue")
result=""
If inputValue&"" = "" Then
Select Case fieldID
Case "txtUsername"
result="用户名不能为空!"
Case "selGender"
result="性别不能为空!"
Case "txtEmail"
result="邮箱不能为空!"
Case "txtPhone"
result="电话不能为空!"
End Select
Else
Select Case fieldID
Case "txtUsername"
result=Validate(inputValue,"^[/u0391-/uFFE5]+$","姓名必须为中文")
Case "txtEmail"
result=Validate(inputValue,"^/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*$","非法的电子邮件格式")
Case "txtPhone"
result=Validate(inputValue,"^((/(/d{2,3}/))|(/d{3}/-))?(/(0/d{2,3}/)|0/d{2,3}-)?[1-9]/d{6,7}(/-/d{1,4})?$","电话号码输入有误")
End Select
End If
response.write result
End If
Function Validate(v,p,e)
Dim objRegExp, strResult
strResult=""
Set objRegExp = New RegExp
With objRegExp
.Global = False
.IgnoreCase = True
.Pattern = p
End With
If objRegExp.Test(v) = False Then
strResult = e
Set objRegExp = Nothing
End If
Validate = strResult
End Function
%>
本文转自
http://www.51city.cn/blog/user1/11/archives/2006/4129.shtml
- 基于AJAX的表单验证--clanY’sBlog
- 一个可以基于Ajax提交的表单验证
- 基于PHP与Ajax的表单验证功能
- AJAX实例的表单验证
- AJAX实例的表单验证
- 简单的Ajax表单验证
- AJAX表单验证的正则
- 基于annotation的表单验证
- Struts2学习笔记3 ――基于AJAX的表单验证
- 基于Ajax的用户名验证
- 基于Ajax.net的验证
- 简单的ajax+servlet表单数据验证
- 表单的ajax验证,以post方式
- 自己实现的ajax表单验证
- 表单提交验证用到的ajax
- 基于Prototype扩展的表单验证
- 基于角色(Role-Based)的表单验证
- 基于Jquery的表单验证框架
- 简洁的表单验证程序
- ORA-02064: 不支持分布式操作
- 谈谈网页一屏有多大?
- 一个封装的很简单的grid,支持排序编辑分页锁定表头,兼容FF
- rundll32.exe命令详解
- 基于AJAX的表单验证--clanY’sBlog
- jQueryWTP
- 850个单词突破口语大关
- ASP.NET连接SQL数据库
- NHibernate Made Simple
- Ubuntu下解决PDF电子文档的中文乱码
- .net datagrid.datasource绑定不知道算不是算BUG
- C#基础概念二十五问 (转帖)
- IIC--ZLG7290键盘和LED驱动