Welcome to WebmasterWorld Guest from 18.210.28.227

Forum Moderators: open

Message Too Old, No Replies

Javascript is not working on firefox

Javascript is not working on firefox

     
4:47 am on Aug 17, 2008 (gmt 0)

New User

10+ Year Member

joined:Aug 17, 2008
posts: 1
votes: 0


Can someone help me, following code working in IE but not in firefox

<head>
<script type="text/javascript">
function validate(loginform)
{
var usernameLen=loginform.username.value.length;
var passwordLen=loginform.password.value.length;
if (!usernameLen>0)
{
changeColor("username");
changeColor("password");
window.alert("Username is missing!");
return false;
}
else
if(!passwordLen>0)
{
changeColor("password");
window.alert("Password is missing!");
return false;
}
else
{
return true;
}
}
function changeColor(id)
{
element = document.getElementById(id);
element.style.background = "lightyellow";
}
</script>
</head>

inside body section

<form action="checkUser" name="loginform" method="post" onsubmit="return validate()">
User Name:<input type="text" id="username" name="username">
Password :<input type="password" id="password" name="password">
<br>
<input type="submit" value="submit">
</form>

10:01 am on Aug 17, 2008 (gmt 0)

Senior Member from GB 

joined:Oct 2, 2003
posts: 1019
votes: 39


Hi there gkmadushan,

and a warm welcome to these forums. ;)

Add this as indicated...


<form action="checkUser" name="loginform" method="post" onsubmit="return validate(
this)">


birdbrain