The verification of the form is a level that is often encountered in the development of web applications. Sometimes we must ensure that some items must be filled out, must be numbers, must be a specified number of bits, etc., at this time, it is necessary to verify that there are 2 ways to verify us:
1. Write the form verification function of JavaScript or VBScript, verify on the client; ;
These two ways have advantages and disadvantages, such as the first mode, and usually use the warning box. Users can quickly complete the form of the form, but the disadvantage is that the user's browser must be supported JavaScript The script, no longer if he closed JavaScript, then! @ # $% & ^ * (Xiaoda has fallen to the ground ^ _ ^); and the compatibility of the second method is better, but the disadvantage is slower (Submit to the server, return) and use is not convenient. This time is mainly to verify using JavaScript methods. Of course, if it is verified in two ways at the same time, it is the most insurance, but (sweat ..........) To exhaust us these programmers :)
The 2 in the form of form verification is explained above, and the concept of dynamically generating JavaScript is concrete. Why do you want to generate? Because this client's verification code is very cumbersome, if you have to write it yourself every time you are quite tired! Friends who are used to DW (DREAMWEAVER) or UD may usually use form-validated plugins, and the code generated after use has no artistic sense, and many of them are not used (code redundancy). Xiaoda is going to say that generates code that is fully compliant with the form.
Disclaimer: Xiaoda is not proficient to JavaScript, here just wants to talk about dynamic generated methods, JS master can change itself.
Then let's start.
1, let's take a look at a simple JavaScript verification code: