This time I will show you how to use regular expressions to implement the verification code of the page form, and what are the precautions for using regular expressions to implement the verification code of the page form. The following is a practical case, let's take a look.
Generally when doing registration page, when users fill in the information, their information needs to be verified, which requires the use of regular expressions, See the example below specifically.
Rendering: (An error message is displayed when the information filled in by the user does not meet the specifications)
I only provide the html structure and js. You can write the style according to your own design draft. I am Different classes are added for correct and incorrect times, and different heights are used. The correct height is small, and the red text of the prompt can be hidden.
html structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
js:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
I believe you have mastered the method after reading the case in this article. Please pay attention for more exciting things. Other related articles on php Chinese website!
Recommended reading:
Detailed graphic explanation of using regular multi-line mode and single-line mode
How to use it in regular expressions Look around
The above is the detailed content of How to use regular expressions to implement verification codes on page forms. For more information, please follow other related articles on the PHP Chinese website!