前端短信验证码
html部分: <tr> <td align="right" width="235px">手机验证码:</td> <td><input id="smsCode" name="smsCode" type="text" /></td> <td> <input type="button" id="sendSms" class="btn btn-primary" value="获取短信验证码" onclick="sendValidateCode(this)" /></td> </tr> js部分: /** * 发送短信验证码 */ function sendValidateCode(obj){ var mobileReg = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/ var countdown = 60, timerTag; var mobile=$("#mobile").val().trim(); if(mobile != ""){ var mobileResult = mobileReg.test(mobile); if(mobileResult){ $.ajax({ url: "verifyCode", type: "post", dataType: "json", async:false, data: {mobile:mobile}, beforeSend: