function submitForm() {
var name = document.getElementById('name');
var password = document.getElementById('password');
if(/^\s*$/.test(name.value) || /^\s*$/.test(password.value)) {
alert('用户名或密码不能为空');
return false;
} else if(name.value=='admin' && password.value =='admin') {
alert('登录成功');
return true;
} else {
alert('登录失败');
return false;
}
}<form action="#" method="POST" onsubmit="return submitForm()" style="width:320px;">
<div>
<label style="display:inline-block;text-align:right;width:100px;">用户名:</label>
<input type="text" id="name" />
<span style="color:red">*</span>
</div>
<div>
<label style="display:inline-block;text-align:right;width:100px;">密码:</label>
<input type="password" id="password" />
<span style="color:red">*</span>
</div>
<div style="text-align:center">
<input type="submit" value="登录" />
<input type="reset" value="重置" />
</div>
</form>
追问可以加下QQ么 还有点问题想问问 帮我看下代码哦
追答加我的群吧 153445235