07-21-2005, 01:35 PM
|
#1
|
|
Banned
Join Date: Aug 2003
Posts: 349
|
javascript - if statement problem
i'm using this as a code to validate fields in a form...this is only a section, but its the one I'm having a problem with:
Code:
function validate(form) {
if (form.topic.value == "-Please select a topic from the list below-")
{
alert("Please select a topic.")
form.topic.focus()
return false
}
if (form.firstname.value.length == 0)
{
alert("Please enter your first name.")
form.firstname.focus()
return false
}
}
the first if is the problem. I dont know what to put after "value" to make it correct. What it is, is a drop down menu, and "-Please select a topic from the list below-" is the default choice (which means they didn't choose anything, and need to).
I have no experience with javascript. This is a code written by someone else, and I just edited it (I have experience in HTML, and PHP, so I know my way around a tad).
Please help if ya can,
|
|
|