ASP automatically generates JavaScript validation functions

Source: Internet
Author: User
Function


<!--#include file= "strcheck.asp"-->
<%
' In the process of writing a program, I need to use
' For I=1 to n
"Response.Write" <input type=text name=name "&n&" > "
' Next
But in JavaScript I don't know the name of the test, so I thought of using ASP to automatically generate JavaScript code to verify text
' By invoking the process, you can test it in a loop-controlled form.
'---------------------------------
' Create JavaScript by ASP
' Write by MIS in 2001,3,31
' MIS@tonghua.com.cn
' Http://www.meetweb.net
'---------------------------------
' The beginning of JavaScript Checkhead
Call Checkhead
' Check if the field is empty the first argument is the name of the box to check, and the second parameter is the prompt error message
Nullcheck "Name1", "It is null string"
Nullcheck "Tel", "It is null string"
' Check if the field for the phone is the first parameter is the name of the box to check, and the second parameter is the prompt 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 you want to check, and 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 email field check the first parameter is the name of the box you want to check, and the second parameter is the prompt error message
Emailcheck "Email", "it must be a email!"
' Check is the date of the field check the first parameter is the name of the box to check, and the second parameter is the prompt error message
Datecheck "Datestr", "It is date"
Nullcheck "Numstr", "It is null string"
' Check if the field is a number the first parameter is the name of the box to check, and the second parameter is the prompt error message
Numericcheck "Numstr", "It must be num!"
' The end of JavaScript Checktail
Call Checktail
%>
<body>
<form name=form1 method=post action= "index.asp" >
Is null: <input type=text name=name1 ><br>
Telephone Inspection: <input type=text Name=tel ><br>
Length inspection: <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>
Digital check: <input type=text name=numstr><br>
<input class=input type= ' submit ' name= ' submit ' value= ' OK ' >
</body>




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.