作者:日落月出星不离_887 | 来源:互联网 | 2014-07-10 02:03
<%*****************************************************************************函数名称:CheckForm_JS(frmName,errStr)功能:用ASP的方法动态写出JavaScript的表单验证的函数checkSubmit()
<%
*****************************************************************************
函数名称:CheckForm_JS(frmName,errStr)
功能:用ASP的方法动态写出
JavaScript的表单验证的函数checkSubmit()
使用方法:1、"&vbCrlf&_
""
Response.Write strShow
End Sub
Function findJS(frmName,errStr)
Dim tmpArr
Dim i
参数值
i=0
获取错误列表,建立数组
tmpArr=Split(errStr,"|")
输出查询条件
Select Case tmpArr(i+1)
Case "0" 必填的Text类型
findJS="if ((document."&frmName&"."&tmpArr(i)&".value)=="""")"&vbCrlf&_
"{"&vbCrlf&_
"window.alert ("&tmpArr(i+2)&");"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".select();"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".focus();"&vbCrlf&_
"return false;"&vbCrlf&_
"}"&vbCrlf
Exit Function
Case "1" 必填的ListMenu类型
findJS="if ((document."&frmName&"."&tmpArr(i)&".value)=="""")"&vbCrlf&_
"{"&vbCrlf&_
"window.alert ("&tmpArr(i+2)&");"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".focus();"&vbCrlf&_
"return false;"&vbCrlf&_
"}"&vbCrlf
Exit Function
Case "2" 必须为数字的Text类型
findJS="if (isNaN(document."&frmName&"."&tmpArr(i)&".value))"&vbCrlf&_
"{"&vbCrlf&_
"window.alert ("&tmpArr(i+2)&");"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".select();"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".focus();"&vbCrlf&_
"return false;"&vbCrlf&_
"}"&vbCrlf
Exit Function
Case "3" 必须为指定位数的Text类型
findJS="if (document."&frmName&"."&tmpArr(i)&".value.length!="&tmpArr(i+3)&")"&vbCrlf&_
"{"&vbCrlf&_
"window.alert ("&tmpArr(i+2)&");"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".select();"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".focus();"&vbCrlf&_
"return false;"&vbCrlf&_
"}"&vbCrlf
Exit Function
Case "4" 必须大于指定位数的Text类型
findJS="if (document."&frmName&"."&tmpArr(i)&".value.length<"&tmpArr(i+3)&")"&vbCrlf&_
"{"&vbCrlf&_
"window.alert ("&tmpArr(i+2)&");"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".select();"&vbCrlf&_
"document."&frmName&"."&tmpArr(i)&".focus();"&vbCrlf&_
"return false;"&vbCrlf&_
"}"&vbCrlf
Exit Function
Case "5" 必须为Email的Text类型
findJS="if ((!emailReg.test(document."&frmName&"."&tmpArr(i)&".value))&&(document."&frmName&"."&tmpArr(i)&".value!=))"&vbCrlf&_
"{"&vbCrlf&_
"window.alert ("&tmpArr(i+2)&");"&vbCrlf&_
"document."&frmName&