<! -- # Include file = "strcheck. asp" -->
<%
I need
For I = 1 to n
Response. Write "<input type = text name = name" & n & ">"
Next
However, I don't know the name of the validation in javascript, so I thought of using ASP to automatically generate JavaScript code to test text
Through the call of the process, you can use the form of cyclic control to test.
JavaScript checkhead
Call checkhead
The first parameter of the field to be checked is the name of the box to be checked, and the second parameter is the error message.
Nullcheck "name1", "it is null string"
Nullcheck "tel", "it is null string"
The first parameter is the name of the box to be checked, and the second parameter is the error message.
Checktel "tel", "it must be a tel! "
Check is the length of the field check the first parameter is the name of the box to check, the second parameter is the prompt error message
The third parameter is the minimum length, and the fourth parameter is the maximum length.
Lengthcheck "changdu", "it is max = 8 and min = 2", "2", "8"
Check is the EMAIL field check. The first parameter is the name of the box to check, and the second parameter is the error message.
Emailcheck "email", "it must be a Email! "
Check is the date field check. The first parameter is the name of the box to check, and the second parameter is the error message.
DateCheck "datestr", "it is date"
Nullcheck "numstr", "it is null string"
The first parameter is the name of the box to be checked, and the second parameter is the error message.
Numericcheck "numstr", "it must be num! "
JavaScript end checktail
Call checktail
%>
<Body>
<Form name = form1 method = post action = "index. asp" onsubmit = "return send (this)">
Empty: <input type = text name = name1> <br>
Phone verification: <input type = text name = tel> <br>
Length test: <input type = text name = changdu> (2-8) <br>
Email check: <input type = text name = email> <br>
Date check: <input type = text name = datestr> (2000-10-1) <br>
Number check: <input type = text name = numstr> <br>
<Input class = input type = submit name = Submit value = OK>
</Body>