Native JavaScript to determine whether it is a mailbox, dangerous characters, verification length, verify URLs, verify decimals, integers, floating point numbers, and other commonly used validation

Source: Internet
Author: User

(71~80verification of this article is mainly 10 more commonly used form verification features, including the mailbox, dangerous characters, verification length, authentication URL, verification decimal, integer, floating point number and other commonly used validation, with these snippets, the usual form validation can also do not need jquery validation plug-in, Hope can help everyone ... 71, native JavaScript determines whether the code code for the mailbox copy is as follows:functionIsemail (str) {varre=/^\w+ ((-\w+) | ( \.\w+)) *\@[a-za-z0-9]+ ((\.| -) [a-za-z0-9]+] *\. [a-za-z0-9]+$/; if(Re.test (str)! =true) {    return false; }Else{    return true; }}72, native JavaScript to determine if there are dangerous characters in the list copy code code as follows:functionIsvalidreg (chars) {varre=/<|>|\[|\]|\{|\}| "|" | ※|0| | |§| |▲|☆|★|◇| |-| |㊣|﹋|⊕|⊙|〒|ㄅ|ㄆ|ㄇ|ㄈ|ㄉ|ㄊ|ㄋ|ㄌ|ㄍ|ㄎ|ㄏ|ㄐ|ㄑ|ㄒ|ㄓ|ㄔ|ㄕ|ㄖ|ㄗ|ㄘ|ㄙ|ㄚ|ㄛ|ㄜ|ㄝ|ㄞ|ㄟ|ㄢ|ㄣ|ㄤ|ㄥ|ㄦ|ㄧ|ㄨ|ㄩ| |▄| ▆|\*|@|#|\^|\\/; if(Re.test (chars) = =true) {    return false; }Else{    return true; }}73, native JavaScript determines whether the string is larger than the specified length copy code code as follows:functionisvalidlength (chars, len) {if(Chars.length <Len) {    return false; }  return true;}74, the native JavaScript judgment string is for the URL case-insensitive copy code code as follows:functionIsvalidurl (chars) {varre=/^ ([hh][tt]{2}[pp]:\/\/|[ hh][tt]{2}[pp][ss]:\/\/) (\s+\.\s+) $/; if(!IsNULL (chars)) {chars=Jstrim (chars); if(Chars.match (re) = =NULL)      return false; Else      return true; }  return false;}75, native JavaScript to determine if the string is a decimal copy code code as follows:functionIsvaliddecimal (chars) {varRe=/^\d*\.? \d{1,2}$/; if(Chars.match (re) = =NULL)    return false; Else    return true;}76, native JavaScript to determine whether the string is an integer copy code code as follows:functionIsnumber (chars) {varre=/^\d*$/; if(Chars.match (re) = =NULL)    return false; Else    return true;}77, native JavaScript determines whether the string is a floating-point copy code code as follows:functionisfloat (str) { for(i=0;i<str.length;i++)  {     if((Str.charat (i) < "0" | | str.charat (i) > "9") && Str.charat (i)! = '. '){      return false; }  }  return true;}78, native JavaScript to determine whether the character is a-za-Z The code of the English letter copy is as follows:functionisletters (str) {varre=/^[a-za-z]+$/; if(Str.match (re) = =NULL)    return false; Else    return true;}79, native JavaScript to determine whether the string code is copied code code as follows:functionIsvalidpost (chars) {varre=/^\d{6}$/; if(Chars.match (re) = =NULL)    return false; Else    return true;}80, native JavaScript to determine if the character is null, the copy code code is as follows:functionIsNULL (chars) {if(Chars = =NULL)    return true; if(Jstrim (chars). length==0)    return true; return false;}

Native JavaScript to determine whether it is a mailbox, dangerous characters, verification length, verify URLs, verify decimals, integers, floating point numbers, and other commonly used validation

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.