...

View Full Version : Field verification problem...



js_coder
07-03-2005, 08:20 AM
Hi,

i have spent hours trying to figure out what the problem was, but never succeeded!
so first things first: I am developping an ecommerce type of website where i have a login page that requires the user a login and a password. Now i am performing all testings on Internet Explorer with no restrictions whatsoever.
I have a javaspript function that checks wether the login field or the password field are empty or not.
So, when testing, i intentionally leave the login field blank, and to this point everything is fine, because the javascript function alerts me and tell me that i have omitted the login field. But...now is where the problem lies. Once i have adjusted to what javascript told me and typed my login, and then purposly leave the login field blank, now javascript will NOT alert me and my identification form will go on to the page that checks login/pwd with my database.
Now here is the relevant code:

first, the form:
<form name="ident" method="POST" action="identification.php" onsubmit="return Check_Identification(this)">
<div align="center">
<p>&nbsp;</p>
<table border="1" cellpadding="0" cellspacing="12" width="260" >
<tr>
<td>Login</td>
<td><input type="text" name="Login"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" name="Pwd" ></td>
</tr>
<tr>
<td colspan="2" class="right"><input type="submit" value="Submit" name="Action"></td>
</tr>
</table>
<p>&nbsp;</p>
</div>
</form>


now, on to the javascript function:
<script type="text/javascript">

function Check_Identification(f)
{
var Test=f.elements['Login'];
if (Test.value == "" || isNonVide(Test.value) == false)
{

alert("please enter login");
Test.focus();
return false;
}

var Test=f.elements['Pwd'];
if (Test.value == "" || isNonVide(Test.value) == false)
{
alert("please enter pwd");
Test.focus();
return false;
}

return true;
}
</script>

Got any idea?

Thanks you!

Harry Armadillo
07-03-2005, 08:37 AM
Where's the function isNonVide()?

PS: use [code] tags!

Willy Duitt
07-03-2005, 06:03 PM
http://www.webdeveloper.com/forum/showthread.php?t=71600



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum