homepage Welcome to WebmasterWorld Guest from 23.22.179.210
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Whats wrong with this Javascript?
Syntax probs
knighty




msg:1492769
 5:15 pm on Oct 30, 2002 (gmt 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

 

bobriggs




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

remove the semicolon at the end of this line:
if ((z.EmployeeName.value == "") (z.PayrollNumber.value == ""));

knighty




msg:1492771
 9:13 am on Oct 31, 2002 (gmt 0)


*ahem* Thanks bob!

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

g1smd




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved