Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to validate a dropdown field

Status
Not open for further replies.

fiuPikeOY

Programmer
Jun 14, 2004
143
US
Hello,

I have a form and 5 fields are required (4 text fields, and 1 dropdown) but I want to validate the dropdown so that it is not = to "Choose One..." which is the first option. What should I add to the code below?

<input name="Submit" type="submit" onclick="MM_validateForm('firstName','','R','lastName','','R','SLID','','R','supName','','R');return document.MM_returnValue" value="Submit" />
<input type="reset" name="Submit2" value="Clear" />

Thanks in advance
 
This is more of a javascript question:
Here's what you do:

Code:
<form name="form" onSubmit="return checkForm(this)">
<select name="dropbox">
 <option value="Choose One..." selected>Choose One</option>
  ...
</select>

function checkForm(form) {
 var validHandle = true;
  if ( form.dropbox.selectedIndex == 0 ) {
    'error: not selected
    validHandle = false;
  }
  return (validHandle == true)
}

[cheers]
Cheers!
Laura
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top