Sub CheckForm_JS(frmName,errStr) Dim tmpArr Dim i Dim strShow '输出JS的字符串 '获取错误列表,建立数组 tmpArr=Split(errStr,",") '写JS for i=0 to UBound(tmpArr) if i<>0 then strShow=strShow&"else "&findJS(frmName,tmpArr(i)) else strShow=strShow&findJS(frmName,tmpArr(i)) end if next '输出 strShow="<script language=javascript>"&vbCrlf&_ "<!--"&vbCrlf&_ "//Power by xiaotian 2002"&vbCrlf&_ "function checkSubmit()"&vbCrlf&_ "{"&vbCrlf&_ "var emailReg = /^[_a-z0-9]+@([_a-z0-9]+/.)+[a-z0-9]{2,3}$/;"&vbCrlf&_ "var pwdReg = /[a-z0-9]$/;"&vbCrlf&_ strShow&_ "else"&vbCrlf&_ "return true;"&vbCrlf&_ "}"&vbCrlf&_ "//-->"&vbCrlf&_ "</script>" Response.Write strShow End Sub
大家注意到这里的一段:
if i<>0 then strShow=strShow&"else "&findJS(frmName,tmpArr(i)) else strShow=strShow&findJS(frmName,tmpArr(i)) end if