Common validation Regular expressions for JS

Source: Internet
Author: User

JS Regular expression Use explanation: various validation syntax

Intege: "^-?" [1-9]//d*$],//integer

Intege1: "^[1-9]//d*$",//Positive integer

Intege2: "^-[1-9]//d*$",//Negative integer

Num: "^ ([+-]?) d*//.? d+$ ",//Digital

NUM1: "^[1-9]//d*|0$",//positive number (positive integer + 0)

NUM2: "^-[1-9]//d*|0$",//negative number (negative integer + 0)

Decmal: "^ ([+-]?) d*//.//d+$ ",//floating point

Decmal1: "^[1-9]//d*.//d*|0.//d*[1-9]//d*$",//positive floating point

Decmal2: "^-([1-9]//d*.//d*|0.//d*[1-9]//d*) $",//negative floating-point number

DECMAL3: "^-?" ([1-9]//d*.//d*|0.//d*[1-9]//d*|0?. 0+|0) $ ",//floating-point number

Decmal4: "^[1-9]//d*.//d*|0.//d*[1-9]//d*|0?" 0+|0$ ",//non-negative floating point number (positive floating point + 0)

DECMAL5: "^ (-([1-9]//d*.//d*|0.//d*[1-9]//d*)] | 0+|0$ ",//non-positive floating-point number (negative floating-point number + 0)

Email: "^//w+ ((-//w+) | ( .//w+)) *//@[a-za-z0-9]+ ((//.| -) [a-za-z0-9]+] *//. [a-za-z0-9]+$],//Mail

Color: "^[a-fa-f0-9]{6}$",//Color

URL: "^http[s]?:/ ([//w-]+//.) +[//w-]+ ([//w-./?%&=]*)? $ ",//url

Chinese: "[//u4e00-//u9fa5//uf900-//ufa2d]+$",//Chinese only

Chandengandnumect: "^[//u4e00-//u9fa5//uf900-//ufa2d//w+]+$",

ASCII: "^[//x00-//xff]+$",//only acsii characters

ZipCode: "^//d{6}$",//ZIP code

Mobile: "^1[0-9]{10}$",//Mobile phone

IP4: "^ (25[0-5]|2[0-4]//d|[ 0-1]//d{2}| [1-9]?//d)//. (25[0-5]|2[0-4]//d| [0-1]//d{2}| [1-9]?//d)//. (25[0-5]|2[0-4]//d| [0-1]//d{2}| [1-9]?//d)//. (25[0-5]|2[0-4]//d| [0-1]//d{2}| [1-9]?//d) $ ",//IP address

Notempty: "^//s+$",//Non-empty

Picture: "(. *)//. (JPG|BMP|GIF|ICO|PCX|JPEG|TIF|PNG|RAW|TGA) $ ",//Picture

RAR: "(. *)//. (rar|zip|7zip|tgz) $ ",//Compressed file

XLS: "(. *)//. (XLS) $ ",//excel www.2cto.com

Date: "^//d{4} (//-|///|/.) d{1,2}//1//d{1,2}$ ",//Date

QQ: "^[1-9]*[1-9][0-9]*$",//qq number

Tel: "^ ([0//+]//d{2,3}-)? ( 0//d{2,3})? (//d{7,8}) (-(//d{3,}))? $ ",//telephone number functions (including verifying domestic area code, international area code, extension number)

Netfaxno: "^[2-9][0-9]{6,7}",

Username: "^//w+$",//used for user registration. Matches a string consisting of a number, 26 letters, or underscores

Letter: "^[a-za-z]+$",//Letters

Letter_u: "^[a-z]+$",//capital letters

letter_l: "^[a-z]+$",//lowercase letters

Idcard: "^[1-9" ([0-9]{14}|[ 0-9]{17}) $ "//ID

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.