Use ASP to dynamically generate JavaScript Form Verification Code
Source: Internet
Author: User
Form Verification is a common issue in WEB application development. Sometimes we must ensure that some items in the form must be filled in, must be numbers, must be a specified number of digits, etc. At this time, we need to use form verification. Generally, there are two common form verification methods: 1. Compile the form verification function SyntaxHighlighter of JavaScript or VBScript. al form verification is a common issue in WEB application development. Sometimes we must ensure that some items in the form must be filled in, must be numbers, must be a specified number of digits, etc. At this time, we need to use form verification. Generally, there are two common form verification methods:
1. Compile the form verification function of JavaScript or VBScript and verify it on the client;
2. After the Form is submitted, use the ASP Method Request. Form to obtain the input value of the Form for judgment, and then return the result, which is verified on the server;
Both methods have their own advantages and disadvantages. For example, the 1st methods are fast and usually use the warning box method. You can quickly complete the form filling as prompted, however, the disadvantage is that your browser must support JavaScript scripts. Otherwise, if JavaScript is disabled! @ # $ % & ^ * (ODA has fallen to the ground ^_^). The compatibility of the 2nd methods is good, but the disadvantage is that the speed is slow (submitted to the server and returned) it is also inconvenient to use. This is mainly verified using JavaScript. Of course, it is the most safe to verify using two methods at the same time, but (Khan ............) It's exhausting our programmers :)
The above explains the method in Form Verification 2. The following describes the concept of dynamic JavaScript generation. Why dynamic generation? This is because the verification code of the client is very cumbersome. If you have to write your own code every time, it is really tiring! Friends who are familiar with DW (Dreamweaver) or UD may usually use Form Verification plug-ins, and the generated code is not artistic, and many cannot be used (Code redundancy ). What Mr. Oda wants to talk about is to generate code that fully complies with the form.
Statement: Mr. Oda is not proficient in JavaScript. Here I just want to talk about the dynamic generation method. The JS experts can modify it by themselves.
So let's get started.
1. Let's take a look at a simple JavaScript verification code:
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.