代码
提交代码
<script>
function beforeSend(){
if(document.getElementById("password").value != document.getElementById("password1").value) return alert("请输入正确的密码");
}
</script>
<form method="post" action="/redister.html" onsubmit='beforeSend()'>
<p><label for="loginName">登录名:</label><input name='loginName' type='text' pattern=".{3,20}">(3~20个字符)</p>
<p><label for="password">登录密码:</label><input id='password' name='password' type='password' pattern=".{6,20}">(至少6位)</p>
<p><label for="password1">重复密码:</label><input id='password1' name='password1' type='password' pattern=".{6,20}">(至少6位)</p>
<p><label for="email">邮箱:</label><input name='email' type='email'>(请输入正确的邮箱地址)</p>
<input type='reset' value='重置'><button type=submit>注册</button>
</form>
运行结果