Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Javascript validation for select box

I can't get this to work on a select box:

<script>
function validate()
{
   
  if( document.myForm.url.value == "" )
   {
     alert( "Please provide a url!" );
     document.myForm.url.focus() ;
     return false;
   }
   if( document.myForm.link_type.value == "" )
   {
     alert( "Please provide a link type!" );
     document.myForm.link_type.focus() ;
     return false;
   }
   return(true);
}
</script>

"link_type" is

<select name="link_type">
<option></option>
<option>facebook</option>
<option>myspace</option>
</select>

I've been playing around with different options, but I can't get anything to work.

Thoughts?
SOLUTION
Avatar of Pierre Cornelius
Pierre Cornelius
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

Smell that? That's the sweet smell of resolution, folks!

Thank you so much!
Good luck with your project!
Glad to help. Good luck.