login form: validate fields

This commit is contained in:
Andrew Dolgov 2007-08-20 06:10:03 +01:00
parent 537625c60c
commit ec6b7adab6

View file

@ -7,6 +7,8 @@
<script type="text/javascript" src="pngfix.js"></script> <script type="text/javascript" src="pngfix.js"></script>
<![endif]--> <![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous/scriptaculous.js"></script>
<script type="text/javascript" src="functions.js"></script> <script type="text/javascript" src="functions.js"></script>
</head> </head>
@ -34,6 +36,26 @@ function languageChange(elem) {
exception_error("languageChange", e); exception_error("languageChange", e);
} }
} }
function validateLoginForm(f) {
try {
if (f.login.value.length == 0) {
new Effect.Highlight(f.login);
return false;
}
if (f.password.value.length == 0) {
new Effect.Highlight(f.password);
return false;
}
return true;
} catch (e) {
exception_error("validateLoginForm", e);
return true;
}
}
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
@ -43,7 +65,7 @@ if (document.addEventListener) {
window.onload = init; window.onload = init;
</script> </script>
<form action="" method="POST" name="loginForm"> <form action="" method="POST" name="loginForm" onsubmit="return validateLoginForm(this)">
<input type="hidden" name="login_action" value="do_login"> <input type="hidden" name="login_action" value="do_login">
<table width="100%" class="loginForm2"> <table width="100%" class="loginForm2">