QQ official to provide the code to verify the QQ number, is the best bar.
| The code is as follows |
Copy Code |
| <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <TITLE>JS Check QQ format correctly </title> <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.exec (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 correct '); }else{ Alert (' QQ format is not correct '); } } --> </script> <input type= "text" id= "QQ"/> <input type= "button" onclick= "Check ()" value= "Query"/> </body> |
Example 2
The 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 ("Please 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 automatically forces the conversation according to 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 number is a number [4--12] bit. Please re-enter! '); Ele.focus (); Return } Url=url+ele.value; url=url+ ' &site=ioshenmue&menu=yes '; Window.location.href=url; } </script>
<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="/> </label> </form> |