验证用户注册项不能为空的javascript代码

来源:百度知道 编辑:UC知道 时间:2024/05/11 00:50:05
帮忙给写一个
(1)验证客户端用户名和密码不能为空的javascript的代码;
(2)验证两次输入的密码是否一样的代码;

<script language="javascript">
function check() {
if (document.frm.username.value=="") {
alert("用户名不能为空");
return false;
}
if (document.frm.pass.value=="") {
alert("密码不能为空");
return false;
}
if (document.frm.pass2.value=="") {
alert("重复密码不能为空");
return false;
}
if (document.frm.pass.value!=document.frm.pass.value2) {
alert("两次输入的密码不相同");
return false;
}
document.frm.submit()
}
</script>
<form method="post" action="" name="frm">
用户名:
<input name="username" type="text" id="username">
密码:
<input name="pass" type="text" id="pass">
重复密码:
<input name="pass2" type="text" id="pass2">
<input type=&