Html
<inputID= "Phone"type= "text"name= "Phone"><inputID= "Checkcode"type= "text"name= "Code"><ButtonID= "Code-btn">Click to send verification code</Button>
JS Code
varCode = "";//Receive Verification Code$ (' #code-btn '). Click (function(){ varCount = 5; varphone=$ ("#phone"). Val ();//Mobile phone number varReg_phone =/1\d{10}/; if(!reg_phone.test (phone)) {//Verify that your phone conforms to the formatAlert ("Fill in the phone number"); return false; } //Start Timing$ ("#code-btn"). attr (' disabled ', ' disabled '); $("#code-btn"). HTML ("Countdown" + Count + "seconds")); varTimer = SetInterval (function() {count--; $("#code-btn"). HTML ("Countdown" + Count + "seconds")); if(count==0) {clearinterval (timer); $("#code-btn"). attr ("Disabled",false);//Enable button$ ("#code-btn"). HTML ("Resend Verification Code")); Code= "";//clear the verification code. If you do not clear, after the time, the input received the verification code is still valid } },1000); //send processing data to the background$.ajax ({type:"POST",//transfer by postDataType: "Text",//data format: JSONURL: ",//Destination AddressData: "phone=" + Phone + "&code=" +code, Error:function(XMLHttpRequest, Textstatus, Errorthrown) {}, Success:function(msg) {}});
JQuery Front-end implementation of mobile phone verification code