JQuery Password Authentication combination cipher with numbers or symbols, cannot use numbers, letters or characters alone, and common regular

Source: Internet
Author: User
Tags alphabetic character

function validpsw () {varPassword = $ (". Password"). Val (); varnum =0; varNumber =0 ; varLetter =0 ; varBigletter =0 ; varchars =0 ; if(Password.search (/[0-9]/) != -1) {num+=1; number=1; }      if(Password.search (/[a-z]/)! =-1) {num+=1; Bigletter=1 ; }      if(Password.search (/[a-z]/)! =-1) {num+=1; Letter=1 ; }      if(Password.search (/[^a-za-z0-9]/) != -1) {num+=1; Chars=1 ; }      if(Num >=2&& (Password.length >=6&& Password.length <= -)) {          $(". Pswspan"). HTML (""); $(". Password"). CSS ("Border","#B0B0B0 solid 1px"); }Else if(Password.length <6|| Password.length > -){          $(". Pswspan"). HTML ("The password is made up of 6-16 characters!"); $(". Password"). CSS ("Border","#B35D5D solid 1px"); }Else if(num = =1){          if(number==1){              $(". Pswspan"). HTML ("not all the numbers!"); }          if(letter==1){              $(". Pswspan"). HTML ("not all the letters!"); }          if(bigletter==1){              $(". Pswspan"). HTML ("not all the letters!"); }          if(chars==1){              $(". Pswspan"). HTML ("not all characters!"); }          $(". Password"). CSS ("Border","#B35D5D solid 1px"); }  }  
View Code

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

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

Only numbers with at least n digits can be entered: "^/d{n,}$".

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

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

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

You can only enter a positive real number with a decimal position: "^[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" *$.

Only characters with a length of 3 can be entered: "^. {3}$ ".

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

You can only enter a string consisting of 26 uppercase English 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 a number and 26 English letters: "^[a-za-z0-9]+$".

You can only enter a string consisting of a number, 26 letters, or underscores: "^/w+$".

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

Verify that it contains ^%& ',; =?$/' characters: "[^%& ',; =?$/x22]+".

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 the 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 the Social Security number (15-bit or 18-digit number): "^/d{15}|/d{18}$".

Validation 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) $ "correct format for;" 01 "~" 09 "and" 1 "~" 31 ".

Use regular expressions to restrict the entry of text boxes in Web Forms:

Use regular expression restrictions to enter only Chinese: onkeyup= "value=value.replace (/[^/u4e00-/u9fa5]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^/u4e00-/u9fa5]/g, ') "

Restrict only full-width characters with regular expressions: onkeyup= "Value=value.replace (/[^/uff00-/uffff]/g,") "Onbeforepaste=" Clipboarddata.setdata (' Text ', Clipboarddata.getdata (' text '). Replace (/[^/uff00-/uffff]/g, ')) "

Use regular expression restrictions to enter only numbers: onkeyup= "Value=value.replace (/[^/d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^/d]/g, ')) "

Use regular expression restrictions to enter only numbers and English: onkeyup= "Value=value.replace (/[/w]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^/d]/g, ')) "

A JavaScript program that uses a regular expression to extract the filename from the URL address, as shown in Page1

S= "Http://www.9499.NET/page1.htm"

S=s.replace (/(. *//) {0,} ([^/.] +). */ig, "$")

Alert (s)

Match double-byte characters (including kanji): [^/x00-/xff]

Application: Calculates the length of a string (a double-byte character length meter 2,ascii character 1)

String.prototype.len=function () {return This.replace ([^/x00-/xff]/g, "AA"). Length;

Regular expression that matches a blank line:/n[/s|] */r

Regular expression matching HTML tags:/< (. *) >.*<///1>|< (. *)//>/

Regular expression matching the leading and trailing spaces: (^/s*) | (/s*$)

String.prototype.trim = function ()

{

Return This.replace (/(^/s*) | ( /s*$)/g, "");

}

Use regular expressions to decompose and convert IP addresses:

The following is a JavaScript program that matches an IP address with a regular expression and translates an IP address into a corresponding value:

function IP2V (IP)

{

re=/(/d+)/. (/d+)/. (/d+)/. (/d+)/g//matching regular expressions for IP addresses

if (Re.test (IP))

{

Return Regexp.$1*math.pow (255,3)) +regexp.$2*math.pow (255,2)) +regexp.$3*255+regexp.$4*1

}

Else

{

throw new Error ("not a valid IP address!")

}

}

However, the above program without regular expression, and directly with the split function decomposition may be more simple, the program is as follows:

var ip= "10.100.20.168"

Ip=ip.split (".")

Alert ("IP value is:" + (IP[0]*255*255*255+IP[1]*255*255+IP[2]*255+IP[3]*1))

Symbol Explanation:

Character

Describe

/

Marks the next character as a special character, or a literal character, or a backward reference, or an octal escape. For example, ' n ' matches the character "n". '/n ' matches a line break. The sequence '//' matches/' and '/("matches" (".

^

Matches the starting position of the input string. If the Multiline property of the RegExp object is set, ^ also matches the position after '/n ' or '/R '.

$

Matches the end position of the input string. If the Multiline property of the RegExp object is set, $ also matches the position before '/n ' or '/R '.

*

Matches the preceding subexpression 0 or more times. For example, zo* can match "z" and "Zoo". * Equivalent to {0,}.

+

Matches the preceding subexpression one or more times. For example, ' zo+ ' can match "Zo" and "Zoo", but not "Z". + equivalent to {1,}.

?

Matches the preceding subexpression 0 or one time. For example, "Do (es)?" can match "do" in "do" or "does".? Equivalent to {0,1}.

N

N is a non-negative integer. Matches the determined n times. For example, ' o{2} ' cannot match ' o ' in ' Bob ', but can match two o in ' food '.

{N,}

N is a non-negative integer. Match at least n times. For example, ' o{2,} ' cannot match ' o ' in ' Bob ', but can match all o in ' Foooood '. ' O{1,} ' is equivalent to ' o+ '. ' O{0,} ' is equivalent to ' o* '.

{N,m}

Both M and n are non-negative integers, where n <= m. Matches at least n times and matches up to M times. For example, "o{1,3}" will match the first three o in "Fooooood". ' o{0,1} ' is equivalent to ' O? '. Note that there can be no spaces between a comma and two numbers.

?

When the character immediately follows any other restriction (*, +,?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. The non-greedy pattern matches the searched string as little as possible, while the default greedy pattern matches as many of the searched strings as possible. For example, for the string "oooo", ' o+? ' will match a single "O", while ' o+ ' will match all ' o '.

.

Matches any single character except "/n". To match any character including '/n ', use a pattern like ' [./n] '.

(pattern)

Match pattern and get this match. The obtained matches can be obtained from the resulting Matches collection, the Submatches collection is used in VBScript, and the $0...$9 property is used in JScript. To match the parentheses character, use '/(' or '/').

(?:p Attern)

Matches pattern but does not get a matching result, which means that this is a non-fetch match and is not stored for later use. This is useful when using the "or" character (|) to combine parts of a pattern. For example, ' Industr (?: y|ies) is a more abbreviated expression than ' industry|industries '.

(? =pattern)

Forward-checking matches the lookup string at the beginning of any string that matches the pattern. This is a non-fetch match, which means that the match does not need to be acquired for later use. For example, ' Windows (? =95|98| nt|2000) ' Can match Windows 2000 ', but does not match Windows 3.1 in Windows. Pre-checking does not consume characters, that is, after a match occurs, the next matching search starts immediately after the last match, rather than starting with the character that contains the pre-check.

(?! Pattern

A negative pre-check matches the lookup string at the beginning of any string that does not match the pattern. This is a non-fetch match, which means that the match does not need to be acquired for later use. For example ' Windows (?! 95|98| nt|2000) ' can match Windows 3.1 ', but does not match Windows 2000 in Windows. Pre-check does not consume characters, that is, after a match occurs, the next matching search starts immediately after the last match, rather than starting with the character that contains the pre-check

X|y

Match x or Y. For example, ' Z|food ' can match "z" or "food". ' (z|f) Ood ' matches "Zood" or "food".

[XYZ]

The character set is combined. Matches any one of the characters contained. For example, ' [ABC] ' can match ' a ' in ' plain '.

[^XYZ]

Negative character set. Matches any character that is not contained. For example, ' [^ABC] ' can match ' P ' in ' plain '.

[A-z]

The character range. Matches any character within the specified range. For example, ' [A-z] ' can match any lowercase alphabetic character in the ' a ' to ' Z ' range.

[^a-z]

A negative character range. Matches any character that is not in the specified range. For example, ' [^a-z] ' can match any character that is not within the range of ' a ' to ' Z '.

/b

Matches a word boundary, which is the position between a word and a space. For example, ' er/b ' can match ' er ' in ' never ', but not ' er ' in ' verb '.

/b

Matches a non-word boundary. ' er/b ' can match ' er ' in ' verb ', but cannot match ' er ' in ' Never '.

/cx

Matches the control character indicated by X. For example,/cm matches a control-m or carriage return. The value of x must be one of a-Z or a-Z. Otherwise, c is treated as a literal ' C ' character.

/d

Matches a numeric character. equivalent to [0-9].

/d

Matches a non-numeric character. equivalent to [^0-9].

/F

Matches a page break. Equivalent to/x0c and/CL.

/n

Matches a line break. Equivalent to/x0a and/CJ.

/R

Matches a carriage return character. Equivalent to/x0d and/cm.

/s

Matches any whitespace character, including spaces, tabs, page breaks, and so on. equivalent to [/f/n/r/t/v].

/S

Matches any non-whitespace character. equivalent to [^/f/n/r/t/v].

/t

Matches a tab character. Equivalent to/x09 and/ci.

/V

Matches a vertical tab. Equivalent to/x0b and/ck.

/w

Matches any word character that includes an underscore. Equivalent to ' [a-za-z0-9_] '.

/w

Matches any non-word character. Equivalent to ' [^a-za-z0-9_] '.

/xn

Match N, where n is the hexadecimal escape value. The hexadecimal escape value must be two digits long for a determination. For example, '/x41 ' matches ' A '. '/x041 ' is equivalent to '/x04 ' & ' 1 '. ASCII encoding can be used in regular expressions:

/num

Matches num, where num is a positive integer. A reference to the obtained match. For example, ' (.) /1 ' matches two consecutive identical characters.

/n

Identifies an octal escape value or a backward reference. If n/n is preceded by at least N of the obtained sub-expression, the nth is a backward reference. Otherwise, if n is the octal number (0-7), N is an octal escape value.

/nm

Identifies an octal escape value or a backward reference. If at least NM has obtained a subexpression before/nm, then NM is a backward reference. If there are at least N fetches before/nm, then n is a backward reference followed by the literal m. If none of the preceding conditions are met, if both N and M are octal digits (0-7), then/nm will match the octal escape value nm.

/nml

If n is an octal number (0-3) and both M and L are octal digits (0-7), the octal escape value NML is matched.

/un

Match N, where N is a Unicode character represented by four hexadecimal digits. For example,/u00a9 matches the copyright symbol (?).

JQuery Password Authentication combination cipher with numbers or symbols, cannot use numbers, letters or characters alone, and common regular

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.