Website Design Table Verification (ASP)

zhaozj2021-02-16  49

Website design form validation (ASP) Author: Liu Wei-mail: support@ceocio.net URL: http: //www.ceocio.net general dynamic website needs to collect user information through a form, or interact with the user, although We believe that the vast majority of people have chosen

The form will be carefully completed, but it is not possible to avoid the boring people to fill the form.

Fill in errors, or they forget to fill in some options. In order to avoid this, developers will add a verification process to form data to form data.

Before or before the server verifies the data fill in the user, if you encounter an error, return to request the user to correct. Cranes in ASP are usually doing this: 1. Verify with JavaScript on the client. 2. Verify with VBScript on the client. 3. Verify with VBScript on the server side. The above mentioned two different environments, server-side and clients, client authentication actually included in the downloaded page, when the user submits the form

Waiting, it is verified directly in the local page that has been downloaded to a local page, which can reduce the server end. The server-side verification is

The page is submitted to the server processing, and the other ASP page on the server will execute the verification of the form before returning the result to the client. Such a disadvantage is that each

Once verified, you have to pass the server and the time is longer. But using server-side verification can achieve better verification. This article is to tell the verification of the server side in the ASP. Before you understand the following introduction methods, you need to think about what you need to be controlled in the form verification problem. Just like software engineering ideas

When you analyze what kinds of respect should be verified. 1. Require the user's input must be Chinese (English or number). 2, require the user's input must be a valid email address. 3. Various different limits for the data entered by the user. 4. Limit the amount of data input by the user. 5, .... In fact, we will encounter many different problems in the site design, and we need to define some regulations and restrictions. Below we will tell the verification method in an example. 1. Verify the number of inputs to assume a text box

" requires users to enter numbers If not isnumeric (Request.form ("TextField") "Request.write" Re-filled "END IF 'Requirements Limit Digital Length, such as you want to enter OICQ number' This example limits the user's input only 4 to 10 Number valid if len (Request.form ("TextField"))> 10 or LEN (Request.form ("TextField")) <4 Ten Response.write "Re-filled" end if of course, using Request.form and Request is The same, just why you write.

2. Verify that the user entered the mail address 'references a generic detection function to describe' Due to the long-term test procedure, it is defined as a function to call Function IsValidemail (email) DIM Names, Name, I, C'check for Valid Syntax in an email address.IsValidEmail = truenames = Split (email, "@") if UBound (names) <> 1 then isValidEmail = false exit functionend iffor each name in names if Len (name) <= 0 then isValidEmail = false exit function end IF for i = 1 to Len (Name) C = LCase (MID (Name, I, 1)) IF INSTR ("AbcdefghijklmnopqrStuvwxyz_-.", c) <= 0 and not isnumeric (c) Then isvalidemail = false exit function end IF next if = "." "or right (name, 1) =". "" "" "" "" "", "", ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, EXIT FUNCTIONEND IFI = LEN (Names (1)) - Instrrev (Names (1), ".") IF i <> 2 and i <> 3 dam isvalidemail = false exit functionend IFIF INSTR (email, "..")> 0 THEN isvalidemail = false IFEND Function 'The above function should be understood, of course, you can modify this code, so that even if the user enters xxx@ccc.ddd is the wrong email address

Because DDD is not a valid domain name. 'You can write if IsValidemail (TRIM (Request (Request ("TextField"))) = false, "End IF 3," Verify the empty form unit "Some information is required to be required to be filled in. Therefore, it is not allowed to be empty, so it is necessary to prompt when the user is input. 'Treatment if the empty unit IF Request.form ("TextField") = "" Ten Response.write "is empty" END IF 4, is it to determine whether the user enters is not a date to first understand the date value format 2002-11-19 'Direct judgment is whether a value is a date if not isdate (Request.form ("TextField") The request.write "Date Filled" End IF and we often use three drop-down frames at design sites to implement the year, month, Three different options, how to link these three values ​​and verify it? First of all, I must establish three pull-up boxes, named the table named Date, Month, Year, and then the background processing, because we have previously at the front desk

Get the three passages of Date, Month, Year, so we must connect them to synthesize a variable to verify and deposit into the database. even

The standard date format expression can be written such: birthday = trim (Request.form ("Year") & "-" & Trim ("Month") & "-" & Trim (Request.form " Date ")) Verify that the converted input is the legal date can be used to use the isdate function: if not isdate (birthday) Then Response.write" Error "end if

5. Do not allow users to enter certain special characters Here we assume that the value passed is Content, we don't allow the input value to be = and% IF INSTR (Request ("" ")," = ")> 0 or Instr (request ("Content"), "%")> 0Then response.write "cannot input = and%" end if

In fact, we can also write a lot of verification functions. I just listed one or two, I hope to help everyone.

转载请注明原文地址:https://www.9cbs.com/read-25820.html

New Post(0)