一個註冊頁面的源碼,有簡訊驗證,頁面源碼簡訊驗證
<html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>註冊</title></head><body><h1 align="center">註冊頁面</h1><!-- <form name="reg" action="#" method="post" > --> <table align="center" valign="middle"> <tr> <td>手機號:</td> <td><input name="mobile" type="text" id="mobile" /></td> </tr> <tr> <td>密碼:</td> <td><input name="password" type="text" id="password" /></td> </tr> <tr><td>驗證碼:</td><td><input name="idcode" type="text" id="idcode" /></td><td><input type="button" name="send" value="擷取" onclick=sendSMS() /></td> </tr> <tr> <td></td> <td><input type="button" name="regster" value="註冊" style="width:140px;" onclick=registerUser() /></td> </tr> </table><!-- </form> --><script src="http://su.bdimg.com/static/superplus/js/lib/jquery-1.10.2_d88366fd.js"></script> <script type="text/javascript" language="javascript">function registerUser() {var mobile = document.getElementById("mobile").value;var password = document.getElementById("password").value;var idcode = document.getElementById("idcode").value;if(mobile==''){alert(" 請輸入電話號碼!");return;}if(password==''){alert(" 請輸入密碼!");return;}if(idcode==''){alert(" 請輸入驗證碼!");return;}$.ajax({ type:'post', url:'/rs/rs', data: JSON.stringify({"code":1,"attribute":[{"key": "mobile", "value": mobile},{"key": "password", "value": password},{"key": "idcode", "value": idcode}]}), async:false, cache:false, dataType:'json', success:function(data){if(data.errcode==0){alert("開戶成功");}else{alert(data.detail);} },error:function(XMLResponse){alert("error");}}); }function sendSMS() {var mobile = document.getElementById("mobile").value;if(mobile==''){window.alert(" 請輸入電話號碼!");return;}$.ajax({ type:'post', url:'/rs/rs', data: JSON.stringify({"code":0,"attribute":[{"key": "mobile", "value": mobile}]}), async:false,dataType:'json', cache:false, success:function(data){if(data.errcode==0){alert("驗證碼已發送,請在"+data.detail+"s內輸入");}else if(data.errcode==1 ){alert("別著急,驗證碼馬上就來了");}else{alert("驗證碼發送失敗");} },error:function(XMLResponse){alert("error");}}); }</script></body></html>