HTML code:
<! DOCTYPE html>
<title></title>
<style type= "Text/css" >
#content #contentmain Table Tbody tr td {
border:0;
height:28px;
}
#content #contentmain table{
Text-align:left;
width:100%;
}
. tabel_2{padding:10px;}
. coninf table td{line-height:30px;}
. Coninf Table{width:100%;line-height:25px;border-collapse:collapse;}
. wxw-table{margin-bottom:10px;}
. wxw-table td{border:1px solid #c5c5c5; height:28px;text-align:center;}
</style>
<script src= "Http://code.jquery.com/jquery-1.4.1.min.js" ></script>
<body>
<div id= "Content" >
<div id= "Contentmain" >
<form>
<table class= "Tabel_2" >
<tbody>
<TR style= "border-top:1px solid #ccc;" >
<TD align= "right" valign= "top" style= "padding-top:10px;" > Mobile number:</td>
<TD style= "padding-top:10px;" >
<textarea rows= "3" cols= "class=" Phones "></textarea>
</td>
</tr>
<tr>
<td></td>
<TD class= "Phone_num" >
Total number: <span style= "color:red" >0</span>
</td>
</tr>
<tr>
<td></td>
<TD >
<input type= "button" Name= "value=" Filter Error "class=" querybtn "id=" Wrongnumber ">
<input type= "button" name= "" value= "re-filter" class= "querybtn" id= "Repeatnumber" >
<input type= "button" name= "" value= "two times Filter" class= "querybtn" id= "Doublenumber" >
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</body>
The interface is as follows:
JS Code:
<script type= "Text/javascript" >
Calculate number
var $phone = $ (". Phones");
var ie = jQuery.support.htmlSerialize;
if (IE) {
$phone [0].oninput = Calculatephone;
}else{
$phone [0].onpropertychange = Calculatephone;
}
function Calculatephone () {
if ($ (". Phones"). Val (). IndexOf (",") >=0) {
var strary = $ (". Phones"). Val (). Split (",");
}else{
var strary = $ (". Phones"). Val (). Split ("\ n");
};
$ (". Phone_num"). HTML ("Total number: <span style= ' color:red ' >" +strary.length+ "</span>");
}
Filter the wrong number
$ ("#wrongNumber"). Click (function () {
if ($ (". Phones"). Val (). IndexOf (",") >=0) {
var strary = $ (". Phones"). Val (). Split (",");
}else{
var strary = $ (". Phones"). Val (). Split ("\ n");
};
Wrong_num (Strary)
})
Re-number Filter
$ ("#repeatNumber"). Click (function () {
if ($ (". Phones"). Val (). IndexOf (",") >=0) {
var strary = $ (". Phones"). Val (). Split (",");
}else{
var strary = $ (". Phones"). Val (). Split ("\ n");
};
Uniqueue (strary);
});
Two times filter
$ ("#doubleNumber"). Click (function () {
if ($ (". Phones"). Val (). IndexOf (",") >=0) {
var strary = $ (". Phones"). Val (). Split (",");
}else{
var strary = $ (". Phones"). Val (). Split ("\ n");
};
var arr = uniqueue (strary);
Wrong_num (arr)
})
Re-number filter function
function Uniqueue (array) {
var arr=[];
var m;
while (array.length>0) {
M=ARRAY[0];
Arr.push (m);
Array=$.grep (Array,function (n,i) {
return n==m;
},true);
}
$ (". Phones"). Val (arr);
$ (". Phone_num"). HTML ("Total number: <span style= ' color:red ' >" +arr.length+ "</span>");
return arr;
}
Error number Filter function
function Wrong_num (strary) {
var ismobile=/^ (?: 13\d|15\d|18\d) \d{5} (\d{3}|\*{3}) $/;
var wrong_num=[];
for (Var i=0;i<strary.length;i++) {
Regcellphone =/^ ([1][0-9]{10})? $/;
Falg=strary[i].search (Regcellphone);
if (falg==-1) {
Wrong_num.push (i);
}
}
for (Var j=0;j<wrong_num.length;j++) {
Strary.splice (wrong_num[i],1);
}
$ (". Phones"). Val (strary);
$ (". Phone_num"). HTML ("Total number: <span style= ' color:red ' >" +strary.length+ "</span>");
}
</script>
Calculate number of input mobile phone number, verify multi-number, filter duplicate number