发表于: 2017-11-26 22:51:58
1 664
今天做的事情:
修改昨日的代码,实现注册登录,调用第三方短信接口。注册成功之后,出现一个问题,不能跳转页面。
function cheockpwd() {
var password = $("[name=password]").val();
var pwd = $(".pwd").val();
// var password = $(".password").val();
// var pwd = $(".pwd").val();
if(password == pwd){
document.getElementById("tishi").innerHTML="<font color='green'>两次密码相同</font>";
document.getElementById("submit").disabled= false;
}else{
document.getElementById("tishi").innerHTML="<font color='red'>两次密码不相同</font>";
document.getElementById("submit").disabled= true;
}
}
function getStatus() {
var phone = $("[name=phone]").val();
if(phone.length>0 &&phone!=null &&phone!=""){
$.ajax({
url:"<%=request.getContextPath()%>/checkPhone",
type:"get",
data:{"phone":phone},
success:function (msg) {
if(msg!=false){
document.getElementById("sc").innerHTML="<font color='green'>验证码发送成功</font>";
document.getElementById("submit").disabled= false;
}else{
document.getElementById("sc").innerHTML="<font color='red'>验证码发送失败</font>";
document.getElementById("submit").disabled= true;
}
}
})
}else {
alert("请填写手机号");
}
}
function tj() {
alert($(".ff").serialize());
var status = $("#status").val();
$.ajax({
url:"/a/user",
type:"post",
data:$(".ff").serialize(),
success:function (msg) {
if(msg == status){
document.getElementById("sta").innerHTML="<font color='green'>验证码输入正确</font>";
location.href="/loginPage";
}else{
document.getElementById("sta").innerHTML="<font color='red'>验证码输入错误</font>";
document.getElementById("submit").disabled= false;
}
}
})
}
</script>
<head>
<title>报名注册页面</title>
</head>
<body>
<!-- method="post" action="<%=request.getContextPath()%>/a/user"-->
<form class="ff">
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<td>用户名</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="text" class="password" name="password"></td>
</tr>
<tr>
<td>确认密码</td>
<td><input type="text" class="pwd" onblur="cheockpwd()"><span id="tishi"></span></td>
</tr>
<tr>
<td>头像</td>
<td><input type="text" name="headpicture"></td>
</tr>
<tr>
<td>手机号</td>
<td>
<input type="text" name="phone">
<input type="button" onclick="getStatus()" value="获取验证码"></td>
</td>
</tr>
<tr>
<td>验证码</td>
<td><input type="text" id="status"> <span id="sc"></span></td>
</tr>
<tr>
<td>邮箱</td>
<td><input type="text" name="email"><span id="sta"></span></td>
</tr>
<tr>
<td colspan="2">
<input type="button" id="submit" value="注册" onclick="tj()">
<input type="reset" value="重置">
</td>
</tr>
</table>
</form>
看了一些基础,在改代码,收获不是很多。
遇到的问题:
应该是逻辑没有理清,导致代码错误很多
收获:
代码完善许多。短信接口掌握不错,明天准备邮件和图片的demo.
评论