asp.net regular formula

Source: Internet
Author: User

Only numbers can be entered: "^[0-9]*$".

Only n digits can be entered: "^d{n}$".

You can enter at least n digits: "^d{n,}$".

You can enter only the number of m~n digits:. "^d{m,n}$"

Only numbers beginning with 0 and not 0 can be entered: ^ (0|[ 1-9][0-9]*) $ ".

You can only enter positive real numbers with two decimal digits: ^[0-9]+ (. [ 0-9]{2})? $ ".

You can only enter positive real numbers with 1~3 decimal places: ^[0-9]+ (. [ 0-9]{1,3})? $ ".

You can only enter a Non-zero positive integer: "^+?" [1-9] [0-9]*$].

You can only enter a Non-zero negative integer: "^-[1-9][]0-9" *$.

You can only enter characters with a length of 3: "^. {3}$ ".

You can only enter a string of 26 English letters: "^[a-za-z]+$".

You can only enter a string consisting of 26 uppercase letters: "^[a-z]+$".

You can only enter a string consisting of 26 lowercase English letters: "^[a-z]+$".

You can only enter a string consisting of numbers and 26 English letters: "^[a-za-z0-9]+$".

You can only enter a string of numbers, 26 English letters, or underscores: "^w+$".

Verify user password: "^[a-za-z]w{5,17}$" is the correct format: start with a letter, length between 6~18, can only contain characters, numbers, and underscores.

Verify that there are ^%& ',; =?$ ' characters: "[^%&",; = $x 22]+ ".

Only Chinese characters can be entered: "^[u4e00-u9fa5]{0,}$".

Verify email Address: "^w+ ([-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) *$ ".

Verify InternetURL: "^http://([w-]+.) +[w-]+ (/[w-./?%&=]*)? $ ".

Verify phone Number: "^ ((d{3,4}-) |d{3.4}-)? d{7,8}$" The correct format is: "Xxx-xxxxxxx", "xxxx-xxxxxxxx", "xxx-xxxxxxx", "xxx-xxxxxxxx", "XXXXXXX" "and" XXXXXXXX ".

Verify ID Number (15-bit or 18-digit): "^d{15}|d{18}$".

Verify 12 months of the year: "^" (0?[ 1-9]|1[0-2]) $ "The correct format is:" 01 "~" 09 "and" 1 "~" 12 ".

Verify one months of 31 days: "^ (0?[ 1-9]) | ((1|2) [0-9]) |30|31) $ "the correct format is;" 01 "~" 09 "and" 1 "~" 31 ".


Use regular expressions to restrict the entry of text boxes in a Web page's form:

The regular expression limit can only be entered in Chinese: onkeyup= "value=value.replace (/[^u4e00-u9fa5]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^u4e00-u9fa5]/g, ') "

Only full-width characters can be entered with regular expression restrictions: onkeyup= "Value=value.replace (/[^uff00-uffff]/g,") "Onbeforepaste=" Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[^uff00-uffff]/g, ') "

Only numbers can be entered with regular expression restrictions: onkeyup= "Value=value.replace (/[^d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^d]/g, ') "

Only numbers and English can be entered with regular expression restrictions: onkeyup= "Value=value.replace" (/[w]/g,

<
Related Article

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.