<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script src= "Http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js" ></script>
<body>
<input id= "mobile" type= "text" value= ""/>
<input id= "sendmess" type= "button" value= "Send verification Code"/></p>
</body>
<script type= "Text/javascript" >
$ (function () {
$ ("#sendMess"). Click (function () {
var mobile=$ ("#mobile"). Val ();
if ("!=$.trim (Mobile)") {
Curcount = count;
$ ("#sendMess"). attr ("Disabled", "true");
$ ("#sendMess"). Val ("Please enter the verification code in" + Curcount + "seconds);
Intervalobj = Window.setinterval (setremaintime, 1000); Start Timer, execute once in 1 seconds
/* $.ajax ({
Type: "POST",
URL: "/test/sendmess",
Data:{mobile:mobile},
Success:function (Mess) {
alert (mess);
});
}
});*/
}else{
Alert ("Please enter your phone number!") ")
}
});
});
Timer handler function
function Setremaintime () {
if (Curcount = = 0) {
Window.clearinterval (intervalobj);//Stop Timer
$ ("#sendMess"). Removeattr ("Disabled");//Enable button
$ ("#sendMess"). Val ("Resend Verification Code");
}
else {
curcount--;
$ ("#sendMess"). Val ("Please enter the verification code in" + Curcount + "seconds);
}
}
</script>
jquery implementation to get the phone verification code countdown effect