JSP中使用js点击注册按钮不显示提示框,代码如下 10
<style>.left{float:left;width:40%;font-size="12px"}.right{float:right;}</style></head...
<style>
.left{float:left;width:40%;font-size="12px"}
.right{float:right;}
</style>
</head>
<body>
<%
ResultSet rs=stat.executeQuery(sql);
if(rs.next()){
String account1=new String(rs.getString("account"));
String password1=request.getParameter("password");
String password2=request.getParameter("passwordd");
}
stat.close();
rs.close();
%>
<Script Language="JavaScript" type="text/javascript">
function registered1()
{
window.alert("你输入的账户名为空");
account=document.registered.account.value;
password=document.registered.password.value;
passwordd=document.registered.passwordd.value;
if(account==""){
alert("你输入的账户名为空");
document.registered.account.foucs();
return;
}else{
String sql="insert into Logininfo values(?,?,?,?,?,?)";
ps=con.prepareStatement(sql1);
ps.setString(1, account1);
ps.setString(2, password1);
}
doucument.registered.submit();
}
</Script>
请输入您的账户信息进行注册<br><br>
<div class="left">
<form name="registered" action="#">
账号 :<input name="account" type="text"><br><br>
密码: <input name="password" type="password"><br><br>
再次输入密码:<input name="passwordd" type="password"><br><br>
<input type="button" onclick="registered1()" value="注册">
</form>
</div>
</body> 展开
.left{float:left;width:40%;font-size="12px"}
.right{float:right;}
</style>
</head>
<body>
<%
ResultSet rs=stat.executeQuery(sql);
if(rs.next()){
String account1=new String(rs.getString("account"));
String password1=request.getParameter("password");
String password2=request.getParameter("passwordd");
}
stat.close();
rs.close();
%>
<Script Language="JavaScript" type="text/javascript">
function registered1()
{
window.alert("你输入的账户名为空");
account=document.registered.account.value;
password=document.registered.password.value;
passwordd=document.registered.passwordd.value;
if(account==""){
alert("你输入的账户名为空");
document.registered.account.foucs();
return;
}else{
String sql="insert into Logininfo values(?,?,?,?,?,?)";
ps=con.prepareStatement(sql1);
ps.setString(1, account1);
ps.setString(2, password1);
}
doucument.registered.submit();
}
</Script>
请输入您的账户信息进行注册<br><br>
<div class="left">
<form name="registered" action="#">
账号 :<input name="account" type="text"><br><br>
密码: <input name="password" type="password"><br><br>
再次输入密码:<input name="passwordd" type="password"><br><br>
<input type="button" onclick="registered1()" value="注册">
</form>
</div>
</body> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询