Let's take a look at this example!
CopyCode The Code is as follows: <HTML>
<Head>
<Title> jquerydemo: quanjiaonum </title>
<SCRIPT src = "jquery. js" src = "jquery. js" type = "text/JavaScript"> </SCRIPT>
<SCRIPT type = "text/JavaScript"> <! --
Function changenum (){
VaR qjnum = $ ("input [@ name = qjnum]"). Val ();
VaR toascii = qjnum. charcodeat ();
If (toascii> 65295 & toascii <65306 & qjnum. Length = 11)
{
VaR Toback = 0;
VaR temp = 0;
VaR unite = "";
For (VAR I = 0; I <qjnum. length; I ++)
{
Toascii = qjnum. charcodeat (I );
Toback = toAscii-65248;
Temp = string. fromcharcode (Toback );
Unite = unite + temp;
}
Alert (unite );
Return true;
}
If (toascii> 47 & toascii <58 & qjnum. Length = 11)
{
Alert (qjnum );
Return true;
}
Else {
Alert ("enter the correct mobile phone number ");
Document. myform. qjnum. value = "";
Return false;
}
}
// --> </SCRIPT>
</Head>
<Form name = "myform" Action = "">
Convert Chinese numbers to Arabic numerals: <input type = "text" id = "qjnum" name = "qjnum"/> <input type = "button" value = "Submit" onclick = "changenum () "/>
</Form>
</Html>
This is a mobile phone number judgment problem! In addition, please note that jquery is also used! Remember to introduce it ......