NET2.0 invisible wings, regular expression of the soul-seekers "moon son original" __web

Source: Internet
Author: User

RegularExpressionValidator Control
Use the RegularExpressionValidator control, and of course you can validate it directly in the background without the RegularExpressionValidator control
The ValidationExpression property has several default authentication methods, but that is far from enough . The ErrorMessage property is an error message.



As shown in the picture, you can click the "..." pop-up window to select the regular expression you want, or write directly to yourself .


In IE, input is not the corresponding format will be the error :


Verify Number:

Only 1 digits can be entered

An expression ^/d$
Describe Match a number
Examples of matches 0,1,2,3
Examples of mismatches

only n digits can be entered
An expression ^/d{n}$ For example ^/d{8}$
Describe Match 8 digits
Examples of matches 12345678,22223334,12344321
Examples of mismatches

You can enter at least n digits
An expression ^/d{n,}$ For example ^/d{8,}$
Describe Match at least n digits
Examples of matches 12345678,123456789,12344321
Examples of mismatches

only m to n digits can be entered
An expression ^/d{m,n}$ For example ^/d{7,8}$
Describe Match m to n digits
Examples of matches 12345678,1234567
Examples of mismatches 123456,123456789

only numbers can be entered
An expression ^[0-9]*$
Describe Match any number
Examples of matches 12345678,1234567
Examples of mismatches E, Qingqing Moon, Http://blog.csdn.net/21aspnet

only one interval number can be entered
An expression ^[12-15]$
Describe Match a number in an interval
Examples of matches 12,13,14,15
Examples of mismatches

You can only enter numbers that begin with 0 and not 0
An expression ^ (0| [1-9] [0-9]*) $
Describe Can be 0, the first number cannot be 0, and the number can have 0
Examples of matches 12,10,101,100
Examples of mismatches 01, Qingqing Moon, Http://blog.csdn.net/21aspnet

only real numbers can be entered
An expression ^[-+]?/d+ (/./d+)? $
Describe Matching real numbers
Examples of matches 18,+3.14,-9.90
Examples of mismatches .6,33s,67-99

positive real numbers that can only be entered N decimal places
An expression ^[0-9]+ (. [ 0-9]{n})? $ with ^[0-9]+ (. [ 0-9]{2})? $ for example
Describe Positive real numbers that match n decimal digits
Examples of matches 2.22
Examples of mismatches 2.222,-2.22,http://blog.csdn.net/21aspnet

only positive real numbers with m-n decimal digits can be entered
An expression ^[0-9]+ (. [ 0-9]{m,n})? $ with ^[0-9]+ (. [ 0-9]{1,2})? $ for example
Describe Positive real numbers that match m to n decimal digits
Examples of matches 2.22,2.2
Examples of mismatches 2.222,-2.2222,http://blog.csdn.net/21aspnet

only positive integers that are not 0 can be entered
An expression ^/+? [1-9] [0-9]*$
Describe Match a positive integer that is not 0
Examples of matches 2,23,234
Examples of mismatches 0,-4,

only negative integers that are not 0 can be entered
An expression ^/-[1-9][0-9]*$
Describe Matches a negative integer that is not 0
Examples of matches -2,-23,-234
Examples of mismatches 0,4,

only n characters can be entered
An expression ^. {n}$ with ^. {4}$ as an example
Describe Match n characters, note that Chinese characters are only 1 characters
Examples of matches 1234,12we,123 Qing, qingqing Moon
Examples of mismatches 0,123,123www,http://blog.csdn.net/21aspnet/

only English characters can be entered
An expression ^. [a-za-z]+$ as an example
Describe Match English characters, any case
Examples of matches Asp,www,
Examples of mismatches 0,123,123www,http://blog.csdn.net/21aspnet/

only uppercase English characters can be entered
An expression ^. [a-z]+$ as an example
Describe Match uppercase characters in English
Examples of matches Net,www,
Examples of mismatches 0,123,123www,

only lowercase English characters can be entered
An expression ^. [a-z]+$ as an example
Describe Match uppercase characters in English
Examples of matches Asp,csdn
Examples of mismatches 0,net,www,

only English characters + digits can be entered
An expression ^. [a-za-z0-9]+$ as an example
Describe Match English characters + numbers
Examples of matches 1ASP,W1W1W,
Examples of mismatches 0,123,123,www,http://blog.csdn.net/21aspnet/

only English characters/digits/underscores can be entered
An expression ^/w+$ as an example
Describe Match English characters or numbers or underscores
Examples of matches 1asp,www,12,1_w
Examples of mismatches 3#,2-4,w#$,http://blog.csdn.net/21aspnet/

Examples of passwords
An expression ^. [a-za-z]/w{m,n}$
Describe Matches the m-n bit character at the beginning of the English character and can only be alphanumeric or underlined
Examples of matches
Examples of mismatches

Verify first letter Capitalization
An expression /b[^/wa-z0-9_][^/wa-z0-9_]*/b
Describe The first letter can only be capitalized
Examples of matches Asp,net
Examples of mismatches http://blog.csdn.net/21aspnet/

Verify URL (with id= Chinese) vs.net2005 no this feature
An expression

^http:////([/w-]+ (/.[ /w-]+) + (//[/w-.///?%&=/u4e00-/u9fa5]*)? $

Describe Verification band Id= Chinese
Examples of matches http://blog.csdn.net/21aspnet/,
http://blog.csdn.net?id= qingqing Month son
Examples of mismatches

Verifying Chinese characters
An expression ^[/u4e00-/u9fa5]{0,}$
Describe Only Chinese characters
Examples of matches Qingqing Moon
Examples of mismatches http://blog.csdn.net/21aspnet/

Verify QQ number
An expression [0-9] {5,9}
Describe 5-9-digit QQ number
Examples of matches 10000,123456
Examples of mismatches 10000w,http://blog.csdn.net/21aspnet/

Verify e-mail (verify MSN number)
An expression /w+ ([-+. '] /w+) *@/w+ ([-.] /w+) */./w+ ([-.] /w+) *
Describe Note that MSN with a non-Hotmail.com mailbox can also
Examples of matches Aaa@msn.com
Examples of mismatches 111@1. http://blog.csdn.net/21aspnet/

Verify the identity card number (rough check, the best server-side tuning class library again fine verification)
An expression ^[1-9] ([0-9]{16}|[ 0-9]{13}) [xx0-9]$

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.