form validation

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

DJ-TM

Thread Starter
Joined
Jul 23, 2003
Messages
38
ok i just need a little help with validating a select box on a form.

Form information:

Form name = raise
Select box name = issue

i have wrote this function

<script type="javascript">
function validate()
{
if document.raise.issue[document.raise.issue.selectedindex].value ="0"
{
alert("Please select an issue type from the drop down list")
else
}
location="confirmation.html"
}
</script>

and i call it using <submit onclick="validate()">

i think im nearly there but its not working, could anyone point me in the right direction.
 
Joined
Aug 4, 2003
Messages
1,228
You really should add some variables, so later down the road you can reuse the script easily by just changing one line, instead of a bunch of code.... but... try this...

if raise.issue.options[raise.issue.selectedIndex].value ="0"

I had a program like this and I set up variables, like this:

stxtNumber=frmPart.optPart.options[frmPart.optPart.selectedIndex].value;
stxtBrand=frmPart.optBrand.options[frmPart.optBrand.selectedIndex].value;

Then you can use it for the validation

if stxtNumber == "0"
{
alert... blah blah
}

Try it...
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top