大神帮帮忙
bootstrap吧
全部回复
仅看楼主
level 7
灰小培💯 楼主
我想做一个登陆窗口,想在js里面验证账号,如果含非法字符,就alert出"用户名不可以包含非法字符",然后重新加载页面,如果不含非法字符,就跳转页面,但是老是无法做到这几步
代码如下,哪里错了,新人刚来,没有悬赏分,大神见谅
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style type="text/css">
body
{
width:350px;
margin:10% auto 10% auto;
}
h1
{
text-align:center;
margin-bottom:20px;
}
#forget_password
{
float:right;
}
p
{
font-size:1.2rem;
}
#p_right
{
float:right;
}
p a
{
color:black;
}
.input-group
{
margin-bottom:10px;
}
</style>
<script type="text/javascript">
function e(v)
{
if(v.match(/[@#\$%\^&\*]+/))
{
alert("用户名不可以包含非法字符");
window.location.replace=("Login.html");
}
else
{
window.location.replace=("Login.html");
window.location.href=("3.html");
}
}
</script>
</head>
<body>
<h1>Welcome</h1>
<p id="p_right"><a href="#">注册账号</a></p>
<p><a href="#">二维码快捷登录</a></p>
<form>
<div class="input-group">
<div class="input-group-addon">账号:</div>
<input type="text" name="user" id="user" class="form-control" placeholder="学号/手机号">
</div>
<div class="input-group">
<div class="input-group-addon">密码:</div>
<input type="password" name="password" class="form-control" placeholder="登录密码">
</div>
<div class="checkbox-inline-block">
<label class="checkbox-inline">
<input type="checkbox">记住密码
</label>
<label id="forget_password"><a href="#">忘记密码</a></label>
</div>
<button type="submit" class="btn btn-lg btn-info col-xs-12" onclick="return e(this.form.user.value)" />登录</button>
</form>
</body>
</html>
2017年04月29日 01点04分 1
level 7
灰小培💯 楼主
人工顶
2017年04月29日 01点04分 2
1