Utilicé un código JavaScript de verificación de formulario generado por ASP en Internet y lo expandí yo mismo. Olvidé el nombre del autor, pero recuerdo claramente que los códigos del Artículo 1 al Artículo 9 son todas las obras originales del autor. En cuanto a los artículos de nueve a quince años, lo agregué yo mismo. Además, debido a mi nivel limitado, desde el artículo 9 hasta el artículo 15, ¿no puede entrar en vigencia a todos ellos? Jaja, en realidad no hay necesidad de publicarlo aquí, porque todos pueden usar este pequeño truco. Posité su función como: cuando no puede encontrar la función durante el desarrollo, puede copiarla aquí. Jaja, porque no tengo un quemador o un disco duro móvil. Realmente no hay forma de llevar estos códigos con usted, pero afortunadamente, puede acceder a Internet en todas partes en Beijing. Así que pon esto aquí, use Ctrl+C, y luego Ctrl+V.
<% '************************************************************************
'Nombre de la función: checkform_js (frmname, errstr)
'Función: use el método ASP para escribir dinámicamente la función de verificación de formulario JavaScript checksubMit ()
'Método de uso: 1. <!-includeFile = url+página donde esta función está ubicada>;
'2. <formosubmit = "javaScript: returnCheckSubMit ()">;
'El autor original ha sido olvidado, el segundo autor de desarrollo: guo.qm
'Última actualización: 2004
'************************************************************************
'ayuda:
'-----------------------------------------------------------------------------------------------
'· Descripción de las partículas:
'frmname: el nombre del campo de formulario
'Errstr: Verifique la lista, como: "Num | 3 | El modelo no debe ser inferior a 8 dígitos | 8, correo electrónico | 5 | Por favor ingrese el formato de correo electrónico correcto", aquí
'Num representa el nombre del campo de formulario, 3 representa el parámetro de verificación, 8 representa el número de dígitos no menos que (opcional)
'
'· Lista de parámetros de verificación:
'0: Tipo de texto requerido
'1: Tipo de listmenu requerido
'2: Debe ser un tipo de texto de número
'3: debe ser el tipo de texto del número especificado de dígitos
'4: El tipo de texto debe ser mayor que el número especificado de dígitos
'5: Debe ser el tipo de texto de correo electrónico
'6: Debe ser AZ o personajes de 0-9
'7: Confirmar que la contraseña y la contraseña deben ser iguales al tipo de texto
'8: Confirme que no es un tipo de texto que se inicia con un número
'9: debe contener el tipo de texto en el formato 10-888888
'10: Tipos de texto que no pueden contener chinos, espacios y otros caracteres ilegales, es decir, solo pueden contener "_" "-"-"" 0-9 "" AZ "AZ"
'11: debe incluir solo el número y "-"
'12: debe ser el tipo de texto de URL correcto
'13: debe ser menor que el número especificado de tipos de texto de dígitos
'14: Tipos de texto que no deben contener etiquetas HTML
'15: confirme que el tipo de selección no está deshabilitado debe seleccionar el formato: elemento de formulario verificado | 15 | Información de solicitud | Artículo de asociación "
'Nota: si hay un menú en cascada, ¡pon el proceso de verificación del menú en cascada en la última inspección! ! ! !
'-----------------------------------------------------------------------------------------------
%>
<%
SubCheckForm_JS (FRMNAME, ERRSTR)
Dimtmparr
Dimi
Cadena de salida de DimStrshow de JS
'Obtenga la lista de errores, cree una matriz
tmParr = split (errstr, ",")
'Escribiendo js
fori = 0toUbound (tmParr)
ifi <> 0
strshow = strshow & "else" & findjs (frmname, tmparr (i))
demás
strshow = strshow & findjs (frmname, tmparr (i))
endif
próximo
'Producción
strshow = "<scriptLanguage = javascript>" & vbcrlf & _
"<!-" & vbcrlf & _
"// powerByguoquanman2004" y vbcrlf & _
"FunctionCheckSubMit ()" y Vbcrlf & _
"{" & vbcrlf & _
"varemailreg =/^[_ a-z0-9]+@([_ a-z0-9]+/.)+[a-z0-9] {2,3} $/;" & vbcrlf & _
"varpwdreg =/[a-z0-9] $/;" & vbcrlf & _
"varuidbeginreg =/^[0-9]+[_ a-z0-9]/;" & vbcrlf & _
"varphonereg = // d {2}-/d {5}/;" & vbcrlf & _
"Varphonedetailreg =/[^0-9/-]/;" & vbcrlf & _
"varuidreg =/[^a-za-z0-9 _/-]/;" & vbcrlf & _
"varhtmlreg =/<(.*)>.*</// 1>/;" & vbcrlf & _
"Varre1 =/^http: //// [a-za-z] [a-za-z0-9/-]*[a-za-z]*/./;" & vbcrlf & _
"Varre2 =/^http: //// [0-9] {1,5} [a-Za-z]*[0-9]*/./;" & vbcrlf & _
"varre3 = //. {2,}/;" & vbcrlf & _
"varre4 = //: {2,}/;" & vbcrlf & _
"varre5 = /// {3,}/;" & vbcrlf & _
"varre6 = //,+/;" & vbcrlf & _
"varre7 = //!+/;" & vbcrlf & _
"varre8 = //@+/;" & vbcrlf & _
"varre9 = //#+/;" & vbcrlf & _
"varre10 = // $+/;" & vbcrlf & _
"varre11 = //^+/;" & vbcrlf & _
"varre12 = //*+/;" & vbcrlf & _
"varre13 = // |+/;" & vbcrlf & _
"Varre14 = //. [A-Z0-9 _ & =? //]*[A-ZA-Z0-9 /// ~] {2,} $/;" & vbcrlf & _
strshow & _
"else" y vbcrlf & _
"returnTrue;" & vbcrlf & _
"}" y vbcrlf & _
"//->" y vbcrlf & _
"</script>"
Respuesta.WritesStShow
Endsub
FunctionFindjs (frmname, errstr)
Dimtmparr
Dimi
'Valor del parámetro
i = 0
'Obtenga la lista de errores, cree una matriz
tmParr = Split (errstr, "|")
'Condiciones de consulta de salida
SelectCasetMParr (i+1)
Tipo de texto requerido para el caso "0" '
findjs = "if ((documento." & frmname & "." & tmParr (i) & ". valor) ==" "" ")" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
Tipo de listmenu requerido para el caso "1"
findjs = "if ((documento." & frmname & "." & tmParr (i) & ". valor) ==" "" ")" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "2" 'debe ser el tipo de texto del número
findjs = "if (isnan (documento." & frmname & "." & tmParr (i) & ". valor))" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "3" 'debe ser el tipo de texto del número especificado de dígitos
findjs = "if (documento." & frmname & "." & tmParr (i) & ". value.length! =" & tmParr (i+3) & ")" & vbcrlf & _ _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "4" 'debe ser mayor que el tipo de texto del número especificado de dígitos
findjs = "if (documento." & frmname & "." & tmParr (i) & ". value.length <" & tmParr (i+3) & ")" & vbcrlf & _ _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "5" 'debe ser el tipo de texto de correo electrónico
findjs = "if ((! emailreg.test (documento." & frmname & "." & tmParr (i) & ". valor)) && (documento." & frmname & "." & tmParr (i) & ". valor! = '')" & vbcrlf & _ _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "6" 'debe ser de AZ o un tipo de texto de caracteres de 0-9
findjs = "if ((! pwdreg.test (documento." & frmname & "." & tmParr (i) & ". valor)) && (documento." & frmname & "." & tmParr (i) & ". valor! = '' '))" & vbcrlf & _ _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "7" 'confirma que la contraseña y la contraseña deben ser iguales al tipo de texto
findjs = "if ((documento." & frmname & "." & tmparr (i) & ". valor)! = (documento." & frmname & "." & tmparr (i+3) & ". valor))" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
Caso "8" 'confirma el tipo de texto que comienza con un número
findjs = "if ((uidBeginReg.test (documento." & frmname & "." & tmParr (i) & ". valor)) && (documento." & frmname & "." & tmParr (i) & ". valor! = '' '))" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
Caso "9" 'confirma el número de teléfono en Formato 10-101212
findjs = "if ((!
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "10" 'confirma que solo texto, incluidas letras en inglés y "-", "_". (Es decir, no incluye los personajes chinos y otros personajes especiales)
findjs = "if (((uidreg.test (documento." & frmname & "." & tmParr (i) & ". valor)) && (documento." & frmname & "." & tmParr (i) & ". valor! = '')" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "11" 'confirma que solo contiene números y "-" (comúnmente usado en números de teléfono y faxes)
findjs = "if (((phonedetailreg.test (documento." & frmname & "." & tmParr (i) & ". valor)) && (documento." & frmname & "." & tmParr (i) & ". valor! = '' '))" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
¡El caso "12" 'confirma si es una URL válida!
findjs = "if (((! re1.test (documento." & frmname & "." & tmparr (i) & ". valor)) && (! re2.test (documento." & frmname & "." & tmparr (i) & ". value))" & _ _
"&& (documento." & frmname & "." & tmParr (i) & ". Value! = '')) ||" & _
"(re3.test (documento." & frmname & "." & tmParr (i) & ". valor)) || (re4.test (documento." & frmname & "." & tmparr (i) & ". valor)) ||" & _
"(re5.test (documento." & frmname & "." & tmParr (i) & ". valor)) || (re6.test (documento." & frmname & "." & tmparr (i) & ". valor)) ||" & _
"(re7.test (documento." & frmname & "." & tmParr (i) & ". valor)) || (re8.test (documento." & frmname & "." & tmparr (i) & ". valor)) ||" & _
"(re9.test (documento." & frmname & "." & tmParr (i) & ". valor)) || (re10.test (documento." & frmname & "." & tmparr (i) & ". valor)) ||" & _
"(re11.test (documento." & frmname & "." & tmParr (i) & ". valor)) || (re12.test (documento." & frmname & "." & tmparr (i) & ". valor)) ||" & _
"(re13.test (documento." & frmname & "." & tmParr (i) & ". valor)) || (! Re14.test (documento." & frmname & "." & tmParr (i) & ". valor))" & _
"&& (documento." & frmname & "." & tmParr (i) & ". valor! = ''))" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
El caso "13" 'confirma que el tipo de texto no es mayor que el número fijo de dígitos
findjs = "if (documento." & frmname & "." & tmParr (i) & ". value.length>" & tmParr (i+3) & ")" & vbcrlf & _ _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
Caso "14" 'confirma el tipo de texto que contiene la etiqueta HTML
findjs = "if (htmlreg.test (documento." & frmname & "." & tmParr (i) & ". valor))" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Select ();" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". focus ();" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf
Extinción
Caso "15"
'============================================================================================================
'Confirme que el tipo de selección no está deshabilitado debe seleccionar el formato: Estado | 15 | ¡Seleccione el nombre de la provincia! | Selcountry | Ciudad | Seleccione Información de la ciudad
'Nota: ¡Cuando se selecciona ININDEX! = 0, el elemento 2 y el elemento 3 están deshabilitados! No es necesario verificar los otros dos elementos
'Cuando el primer elemento seleccionadoindex == 0 del menú en cascada, el INDEX seleccionado del segundo elemento no puede ser 0, y cuando el segundo elemento seleccionado INDEX! = 0 del segundo elemento, el ININDEX seleccionado del tercer elemento tampoco puede ser 0.
'Este artículo se utiliza para verificar los tres menús en cascada del país/provincia/ciudad. Cuando el país no es China, la provincia y la ciudad no pueden ser completadas. Cuando es China, la provincia y la ciudad relativa deben completarse.
findjs = "if (documento." & frmname & "." & tmParr (i+3) & ". SelectedIndex == 0)" & vbcrlf & _
"{" & vbcrlf & _
"if (documento." & frmname & "." & tmParr (i) & ". selectedIndex == 0)" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Focus;" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf & _
"Elseif (documento." & frmname & "." & tmParr (i) & ". SelectedIndex! = 0)" & vbcrlf & _
"{" & vbcrlf & _
"if (documento." & frmname & "." & tmParr (i+4) & ". SelectedIndex == 0)" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+5) y "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i+4) & ". Focus;" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf & _
"}" y vbcrlf & _
"}" y vbcrlf
Extinción
El caso "16" 'confirma que el tipo de selección no está deshabilitado debe seleccionar el formato: Artículo de formulario verificado | 16 | Información de solicitud | Artículo de asociación "Nota: Cuando el elemento asociado es el primer elemento, ¡comienza la confirmación!
findjs = "if (documento." & frmname & "." & tmParr (i+3) & ". SelectedIndex! = 0)" & vbcrlf & _
"{" & vbcrlf & _
"if (documento." & frmname & "." & tmParr (i) & ". selectedIndex == 0)" & vbcrlf & _
"{" & vbcrlf & _
"Window.alert ('" & tmParr (i+2) & "');" & vbcrlf & _
"Documento." & frmname & "." & tmParr (i) & ". Focus;" & vbcrlf & _
"returnfalse;" & vbcrlf & _
"}" y vbcrlf & _
"}" y vbcrlf
Extinción
EndSelectar
Función final
%>