& lt; Input the id="mobile" type="tel" placeholder="phone number" value="" & gt;
$(function () {
Var InterValObj;//timer variables, control time
Var count=60;//interval function, 1 second to perform
Var curCount;//the number of seconds remaining
$(' # btnCheckCode). Click (function () {
If ($(" # mobile "). The val ()=="") {
Tankuang (240, "please enter your mobile phone number");
return false;
}
if(! $(" # mobile "). Val () the match (/^ 1 [3 4 5 6 7 | | | | | | 8, 9] {1} [0-9] {9} $/)) {
Tankuang (240, "mobile phone number format is not correct! Please input again!" );
return false;
}
Var captcha1=new TencentCaptcha (' 211222204 ', function (res) {
If (res. Ret===0) {
Mobile=$var. Trim ($(" # mobile "). Val ());
//save tbl_smsCode, and send SMS
GenerateCode (mobile);
}
});
Captcha1. The show ();//display verification code
});
//send the phone to the background, the verification code
Var generateCode=function (mobile, verify) {
Var args={
Mobile: mobile,
Verify: verify,
}
$.post (' send. PHP, args, function (result) {
If (result. The status==0) {
Tankuang (240, "success");
//60 s bottom
CurCount=count;
$(" # btnCheckCode "). Attr (" disabled ", "true");
$(" # btnCheckCode "). The addClass (" button - light ");
$(" # btnCheckCode "). The HTML (curCount + "& amp; nbsp; S ");
InterValObj window.=setInterval (SetRemainTime, 1000);//start the timer, 1 second to perform a
}
The else {
Tankuang (200, "fails, please contact us to verify");
}
}, "json");
};
//timer handler
Var SetRemainTime=function () {
If (curCount==0) {
Window. ClearInterval (InterValObj);//stop the timer
$(" # btnCheckCode "). RemoveAttr (" disabled ");//enable button
$(" # btnCheckCode "). RemoveClass (" button - light ");
$(" # btnCheckCode "). The HTML (" get verification code ");
}
The else {
CurCount -;
$(" # btnCheckCode "). The HTML (curCount + "& amp; nbsp; S ");
}
};
The function tankuang (pWidth, content, url)
{
$(" # MSG "). The remove ();
Var HTML='& lt; Div id="MSG" style="position: fixed; Top: 50%; width:100%; Height: 30 px; The line - height: 30 px; Margin - top: 15 px; Z - index, 9999;">'+ content + & lt;/p>