Написал страницу для проверка пароля и email помогите в чем проблема? пароль не проверяется на количество лимволов
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Зарегистрироваться на странице</title>
<style type="text/css">
.header {width:100%; height:20px; background-color:#00FF00; padding:20px; text-align:center}
.left_col {width:120px; height:20px; background-color:#dedddc; padding:15px; vertical-align:top}
.center_col {width:900px; background-color:#95918c; padding:15px; vertical-align:top}
TABLE {
border: 1 px double #000; /* Рамка вокруг таблицы */
}
TD, TH {
padding: 5px; /* Поля вокруг текста */
border: 1px solid #000000; /* Рамка вокруг ячеек */
background: ; /* Цвет фона ячеек */
}
</style>
<style>
input:focus {
background: #FA6;
outline: none; /* убрать рамку */
}
</style>
<style>
#validEmail
{
margin-top: 4px;
margin-left: 9px;
position: absolute;
width: 16px;
height: 16px;
}
.text
{
font-family: Arial, Tahoma, Helvetica;
}
</style>
</head>
<div id="wrapper">
<form method="POST" action="index.php" onsubmit="return Validate()" name="regedit">
<table cellpadding="0" cellspacing="0" width="100%" align="center" border="1">
<tr>
<td colspan="3.1"><p><b><p style="font-size:24px">Анкета Web-разработчика</b></p></p>
<div>
<tr>
<div>
<td class="left_col">Регистрационное имя</a></td>
<td class="center_col"><input type="text" name="username" class="textInput ">
</td>
</div>
</tr>
</div>
<div>
<tr>
<td class="left_col">E-mail:</a></td>
<td class="center_col"><input type="email" name="email" class="textInput"><span id="validEmail"></span>
<div id="email_error" class="val_error"></div>
</tr>
</div>
<div>
<tr>
<td class="left_col">Пароль:</a></td>
<td class="center_col">
<div>
<input type="password" name="password" class="textInput">
</div>
<div>
<input type="password" name="password_confirmation" class="textInput">Подтвердите пароль
<div id="password_error" class="val_error"></div>
</div>
</tr>
</div>
<tr>
<td class="left_col">Ваша спетциализация</a></td>
<td class="center_col"> <form>
<select name="food">
<option value="r1">Web-мастер</option>
<option value="r2">Web-разрабочитк</option>
<option value="r3">Web-тесте</option>
</select>
</p>
</form>
</td>
</tr>
<tr>
<td class="left_col">Пол</a></td>
<td class="center_col"><input type="radio" name="sex" value="male"/>
М<input type="radio" name="sex" value="female"/>
Ж<br/></td>
</tr>
<tr>
<td class="left_col">Ваши навыки</a></td>
<td class="center_col"><form name="travel" action="http://ab-w.net/info.php" method="get">
<input type="checkbox" name="transport" value="airplane" checked="checked" /> знание HTML и CSS<br />
<input type="checkbox" name="transport" value="train" /> знание Perl<br />
<input type="checkbox" name="transport" value="car" /> знание ASP<br />
<input type="checkbox" name="transport" value="bus" /> знание Adobe Photoshop<br />
<input type="checkbox" name="transport" value="car" /> знание JAVA<br />
<input type="checkbox" name="transport" value="bus" /> знание JavaScrript<br />
<input type="checkbox" name="transport" value="bus" /> знание Flash<br />
</form></td>
</tr>
<tr>
<td class="left_col">Дополнительные сведения о себе</a></td>
<td class="center_col"><div class="comment"><textarea cols="40" rows="5"></textarea></div></td>
</tr>
<tr>
<td colspan="4" class="footer"> <div>
<input type="submit" class="btn" name="" value="Зарегистрироваться"/><input type="reset" value="Очистить форму">
</div></td>
</tr>
</form>
</div>
<script type="text/javascript">
var username = document.forms["regedit"]["username"];
var email = document.forms["regedit"]["email"];
var password = document.forms["regedit"]["password"];
var password_confirmation = document.forms["regedit"]["password_confirmation"];
var name_error = document.getElementById("name_error");
var email_error = document.getElementById("email_error");
var password_error = document.getElementById("password_error");
username.addEventListener("blur", nameVerify, true);
email.addEventListener("blur", emailVerify, true);
function Validate(){
if(username.value == ""){
username.style.border = "1px solid red";
return false;
}
if(email.value == ""){
email.style.border = "1px solid red";
return false;
}
if (password.value != password_confirmation.value) {
password.style.border = "1px solid red";
password_confirmation.style.border = "1px solid red";
return false;
}
if (password.value == "" || password_confirmation.value == "") {
password.style.border = "1px solid red";
password_confirmation.style.border = "1px solid red";
password.focus();
return false;
}
}
function nameVerify(){
if (username.value != "") {
username.style.border = "1px solid #110E0F";
return true;
}
}
function emailVerify(){
if (email.value != "") {
email.style.border = "1px solid #110E0F";
return true;
}
}
function val(){
if(frm.password.value == "")
{
alert("");
frm.password.focus();
return false;
}
if((frm.password.value).length < 4)
{
alert("");
frm.password.focus();
return false;
}
if(frm.confirmpassword.value == "")
{
alert("");
return false;
}
if(frm.confirmpassword.value != frm.password.value)
{
alert("");
return false;
}
return true;
}
</script>
</body>
</html>