<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="获取" οnclick=sendSMS() /></td>
</tr>
<tr>
<td></td>
<td><input type="button" name="regster" value="注册" style="width:140px;" οnclick=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>
一个注册页面的源码,有短信验证
最新推荐文章于 2024-03-07 20:50:17 发布