国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) Use ASP to dynamically generate JavaScript form verification code

Use ASP to dynamically generate JavaScript form verification code

Nov 25, 2016 am 09:53 AM
asp

Form validation is a level often encountered in developing WEB applications. Sometimes we have to ensure that certain 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, we commonly use two methods of form verification:
1. Write a JavaScript or VBScript form verification function to verify on the client side;
2. After the form is submitted, use the ASP method Request.Form to get the input value of the form for judgment, and then return the result. This is verified on the server side;

These two methods have their advantages and disadvantages. For example, the first method is faster and usually uses an alert box. The user can quickly complete the form filling in according to the prompts. However, the disadvantage is that the user's browser must be Supports JavaScript scripts, otherwise if he turns off JavaScript, then!@#$%&^* (Oda has fallen to the ground^_^); while the second method has better compatibility, but the disadvantage is speed It is relatively slow (submitted to the server and returned) and inconvenient to use. This time I mainly use JavaScript to verify. Of course, it is safest to use two methods to verify at the same time, but (sweat...) it will make us programmers exhausted:)

 The form is explained above For the two methods of verification, let’s talk about the concept of dynamically generating JavaScript in detail. Why do we need to generate it dynamically? Because this kind of client-side verification code is very cumbersome, it would be really tiring if you have to write it yourself every time! Friends who are used to DW (Dreamweaver) or UD may usually use form validation plug-ins. The code generated after use is not artistic, and many of them are unused (code redundancy). What Oda wants to talk about is to generate code that fully conforms to the situation of the form.

Disclaimer: Xiaotian is not proficient in JavaScript. I just want to talk about the dynamic generation method. JS masters can modify it themselves.

 Then let’s get started.

1. Let’s first take a look at a simple JavaScript verification code:







This code is the name form item of the verification form form1, and the content must be filled in. Here are several key parts: form field names, form item names, and judgment statements; these are the keys to our ASP function writing below.

2. How to generate JavaScript code. The simplest is to use Response.Write to output. For example, the above code output can be:

<%
Response.Write ""&vbCrlf&_
%>

The vbCrlf here is a carriage return and line feed,& is the connector, & _ is the character for code newline concatenation.

3. The head and tail of this code are basically fixed. What changes is the if judgment part in the middle. We can write this part as a function first. Oda has already written one. You can refer to it. The following is Code:

Function findJS(frmName,errStr)
Dim tmpArr
Dim i
Parameter value
i=0
Get the error list and create an array
tmpArr=Split(errStr,"|")
Output query conditions
Select Case tmpArr (i+1)
Case "0" Required Text type
findJS="if ((document."&frmName&"."&tmpArr(i)&".value)=="""")"&vbCrlf&_ Please note when reprinting Source: Use ASP to dynamically generate JavaScript form verification code

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the built-in objects in asp? What are the built-in objects in asp? Nov 09, 2023 am 11:32 AM

ASP built-in objects include Request, Response, Session, Application, Server, Session.Contents, Application.Contents, Server.CreateObject, Server.MapPath, Server.Execute, Server.Transfer, etc. Detailed introduction: 1. Request: represents HTTP request object, etc.

What are the asp development tools? What are the asp development tools? Oct 23, 2023 am 11:02 AM

ASP development tools include Visual Studio, Dreamweaver, FrontPage, EditPlus, UltraEdit, SQL Server Management Studio, RAD Studio, Delphi, Asp.NET and Oracle SQL Developer.

What are the methods for detecting asp vulnerabilities? What are the methods for detecting asp vulnerabilities? Oct 13, 2023 am 10:42 AM

Methods include: 1. Use specialized vulnerability scanning tools; 2. Manual testing to discover and verify vulnerabilities in ASP applications; 3. Conduct security audits to check the code and configuration files of ASP applications; 4. Use vulnerability exploitation frameworks; 5. Review the code of the ASP application.

asp scanning tool vulnerability detection asp scanning tool vulnerability detection Oct 13, 2023 am 10:45 AM

ASP scanning tool vulnerability detection: 1. Select the appropriate scanning tool; 2. Configure the scanning target in the scanning tool; 3. Configure scanning options as needed; 4. After the configuration is completed, start the scanning tool to start scanning; 5. Scanning tool A report will be generated listing the detected vulnerabilities and security issues; 6. Fix the detected vulnerabilities and security issues according to the recommendations in the report; 7. After fixing the vulnerability, re-run the scanning tool to ensure that the vulnerability has been successfully exploited repair.

How to connect asp to access database How to connect asp to access database Oct 18, 2023 am 11:33 AM

Connection method: 1. Use ADO to connect to the database; 2. Use DSN to connect to the database; 3. Use the connection string to connect to the database.

How to manually detect vulnerabilities in asp How to manually detect vulnerabilities in asp Oct 13, 2023 am 10:49 AM

ASP manual detection of vulnerabilities: 1. Check the ASP application's verification and filtering mechanism for user input; 2. Check the ASP application's encoding and filtering mechanism for output data; 3. Check the ASP application's authentication and session management mechanism; 4. Check the ASP application's permission control on files and directories; 5. Check the ASP application's handling of errors; 6. Check the ASP application's database security; 7. Check the ASP application's configuration file and server configuration.

iPhone average selling price rises 14% as iPhone 13 drives record revenue iPhone average selling price rises 14% as iPhone 13 drives record revenue Apr 14, 2023 pm 03:22 PM

iPhone average selling price (ASP) achieved double-digit growth last year, growing 14% year-on-year. The popularity of iPhone 13 is a key driver, helping push the global smartphone market as a whole to a record annual revenue of $448B. Despite parts shortages, the smartphone market grew 7% year-on-year, with Apple taking by far the largest share... Market intelligence firm Counterpoint released its latest estimates today. According to the latest research from Counterpoint's MarketMonitorService, the global smartphone market revenue will exceed US$448 billion in 2021. Even as component shortages and COVID-19 restrictions continue to disrupt global supply

How to do asp security audit vulnerability detection How to do asp security audit vulnerability detection Oct 13, 2023 am 10:54 AM

ASP security audit vulnerability detection steps: 1. Collect relevant information about the ASP application; 2. Carefully analyze the source code of the ASP application; 3. Check the ASP application's verification and filtering mechanism for user input; 4. Check the application's Encoding and filtering mechanism of output data; 5. Check the application's authentication and session management mechanism; 6. Check the application's permission control on files and directories; 7. Check the application's handling of errors; 8. Check the application's Configuration files and server configuration; 9. Fix vulnerabilities.

See all articles