<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="register.html" method="post"> <!--onsubmit="return sub()"-->
<table>
<tr>
<td>邮箱</td>
<td>
<input type="text" name = "email" id="email">
</td>
<td id="e1"></td>
</tr>
<tr>
<td>密码</td>
<td>
<input type="text" name="code" id="code">
</td>
<td id="c1"></td>
</tr>
<tr>
<td colspan="2" align="center">
<button >提交</button>
<button type="submit">注册</button>
</td>
</tr>
</table>
</form>
</body>
<script>
function sub() {
var email = document.getElementById("email").value;
var code = document.getElementById("code").value;
var e1 = document.getElementById("e1");
var c1 = document.getElementById("c1");
if(email == ""){
e1.innerHTML = "请输入邮箱";
return false;
}
if(code == ""){
c1.innerHTML = "请输入密码";
return false;
}
return true;
}
</script>
</html>
以上就是代码,前端实在垃圾,仅作参考,没啥大用