代碼
提交代碼
<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>
運行結果