Js QQ number Regular Expression Summary

Source: Internet
Author: User

The composition principle of QQ numbers is very simple. One is that the length is at least five characters, and the maximum length is 2300000000 characters so far. This is the information provided by the QQ official website, below I will summarize some common examples of Regular Expression for QQ numbers. If you need them, please refer to them.

The QQ official code for verifying the QQ number is the best.

The Code is as follows: Copy code

<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> check if the QQ format is correct in JS. </title>
</Head>
<Body>
<Script type = "text/javascript">
<! --
Function $ (id ){
Return document. getElementById (id );
}
Function checkQQ (qq ){
// Qq = qq. replace (/(^ s *) | (s * $)/g ,"");
Var patrn =/^ [1-9] d {4, 9} $ /;
If (patrn.exe c (qq )){
Qq = parseInt (qq, 10 );
If (qq> 10000 & qq <2300000000 ){
Return true;
}
}
Return false;
}
Function check (){
Var qq =$ ('qq'). value;
If (checkQQ (qq )){
Alert ('qq format is correct ');
} Else {
Alert ('incorrect qq format ');
}
}
// -->
</Script>
<Input type = "text" id = "qq"/>
<Input type = "button" onclick = "check ()" value = "query"/>
</Body>
</Html>

Example 2

Pure QQ number

The Code is as follows: Copy code

<Script language = "javascript">
Function checkfrom (){
Var num = document. getElementById ("text"). value;
Regex =/^ [1-9] d {5, 8} $ /;
If (! Regex. test (num ))
{
Alert ("enter the correct QQ number ")
}
Else
{
Alert ("correct ");
}
}
</Script>

<Input type = "text" id = "text" name = "text">
<Input type = "Submit" id = "Submit" name = "submit" value = "check" onclick = "checkfrom ();">

Example 3

This automatic forced dialog is based on the QQ number entered by the user

The Code is as follows: Copy code

<Script>
Function doload (){
Window. resizeTo (400,300 );
}
Function turnToURL (){
Var ele = form1.qq;
Var re = new RegExp ('^ [0-9] {4, 12}', "I ");
Var url = 'HTTP: // wpa.qq.com/msgrd? V = 1 & Uin = ';
If (ele. value. match (re) = null ){
Alert ('qq No. Is a digit [4--12. Enter again! ');
Ele. focus ();
Return;
}
Url = url + ele. value;
Url = url + '& Site = ioshenmue & Menu = yes ';
Window. location. href = url;
}
</Script>
</Head>

<Body onload = "doload ();">
<Form name = "form1" action = "" method = "post" onsubmit = "turnToURL ();">
<Input name = "qq" type = "text" id = "qq"/>
<Label>
<Input type = "submit" name = "button" id = "button" value = "submit"/>
</Label>
</Form>

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.