Welcome to WebmasterWorld Guest from 54.146.221.231

Forum Moderators: open

Message Too Old, No Replies

Whats wrong with this Javascript?

Syntax probs

     
5:15 pm on Oct 30, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 8, 2001
posts:690
votes: 0


Someone please explain - why do I get a syntax error for the line where the else statement is?

just a simple script to check if a couple form fields are empty

<script>
function Check()
{
z = document.PersonalChange;

if ((z.EmployeeName.value == "") ¦¦ (z.PayrollNumber.value == ""));
{
alert('You need to enter your name');
return false;
}
else
{
alert('woohoo');
return true;
}
}
</script>

--for the form I have....

<form method=post action="success.html" name="PersonalChange" onSubmit="return Check();">

but i get an error before I get a chance to execute the form

5:21 pm on Oct 30, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 10, 2001
posts:748
votes: 0


remove the semicolon at the end of this line:
if ((z.EmployeeName.value == "") (z.PayrollNumber.value == ""));
9:13 am on Oct 31, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 8, 2001
posts:690
votes: 0



*ahem* Thanks bob!

I KNEW it would be something like that, normally dont put enough in ;)

10:16 pm on Oct 31, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


<script> should be :
<script language="javascript" type="type/javascript"> if you want it to validate.