Javascript syntax error - basic question

Hi, I’ve just started writing a bit of javascript and have got a syntax error on the ‘else’ line of the following code. Can anyone tell me what’s wrong with it, it’s in the JS header event of a form:

function validate()

{

var f = document.forms[0];

If (f.eventname.value == null)

{

return false;

}

else

{

return true;

}

}

Thanks

Dan

Subject: Javascript syntax error - basic question

There are a few things wrong with the code. There may be a problem with the object your code is meant to work on. JavaScript is case-sensitive, so unless your field name actually is “eventname” (as opposed to “EventName” or some such), then you’ll find that is is “null or not an object”. By the way, “null” is not the same as an empty string – it means something that literally ain’t there. Finally, “If” should be “if”. Your code, then, should probably have looked like this:

function validate()

{

var f = document.forms[0];

if (f.EventName.value == ‘’)

{

return false;

}

else

{

return true;

}

}

Subject: RE: Javascript syntax error - basic question

Thanks Stan

Yes it was the case sensitive thing with the if statement.

It seems bad practice in my lotusscript is catching me out.

Dan