Page JavaScript Partial validation summary

Source: Internet
Author: User
JavaScript Regular verifies that the string is empty
Purpose: Check if the input string is empty or all are spaces
The input quantity is a string: str

Return: Returns True if the input amount is NULL or FALSE

   function IsNull (str) {
    if (str = "") return true;
    var Regu = "^[]+$";
    var re = new RegExp (regu);
    return Re.test (str);
    
Regular expression Validation mailbox
JavaScript form verification Email to determine whether an input amount is a mailbox email, implemented through regular expressions.
Check Email mailbox
function Isemail (str) {
       var reg =/^ ([a-za-z0-9_-]) +@ ([a-za-z0-9_-]) + ((\.[ a-za-z0-

9_-]{2,3}) {1,2}) $/;
       return Reg.test (str);
JavaScript Regular verifies that the input is Chinese
JavaScript form validation is Chinese, determines whether an input is Chinese and is implemented through regular expressions.
JavaScript form validation is Chinese
Check to see if the Chinese
function Ischn (str) {
      var reg =/^[u4e00-u9fa5]+$/;
      if (!reg.test (str)) {return
       false;
      }
      return true;
}
JavaScript regular verifies different strings of two strings
JavaScript is comparing two strings
JavaScript is comparing two strings,
is to use regular expressions to quickly compare different characters of two strings.
<script language= "JavaScript" >
var str1 = "Find a comparison string processing function";
var str2 = "Seek two or three comparison string processing";
var re = new RegExp (? =.*?) [^ "+ str1 +"] (?=.*?)| (?=.*?) [^ "+ str2

+"] (? =.*?) "," G ");
var arr;
while ((arr = re.exec (str1 + str2))!= null)
{
   document.write (arr);
}
</script>
JavaScript Regular verifies the input in Chinese or uppercase letters
JavaScript forms validate Chinese capital letters to determine whether an input is an English letter in Chinese or uppercase, and is implemented through regular expressions.
Check whether it is a valid real name and can only contain Chinese or uppercase English letter
function Isvalidtruename (strName) {
      var str = Trim (strName);   To determine whether it is all English or Chinese, you can include a space
      var reg =/^[a-z u4e00-u9fa5]+$/;
      if (Reg.test (str)) {return
       false;
      }
      return true;
}
JavaScript form authentication phone number
The JavaScript form verifies the phone number to determine whether an input is a phone number and is implemented through a regular expression.
Check the phone number
function Istel (str) {
       var reg=/^ ([0-9]|[ \-]) +$/g;
       if (str.length<7 | | str.length>18) {return
        false;
       }
       else{return
         reg.exec (str);
       }

to learn more about the validation problem with JavaScript, click JavaScript 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.