[thelist] How to validate a <select><option>

Jeff jeff at members.evolt.org
Mon May 22 22:13:28 2000


:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Warden, Matt <mwarden@odyssey-design.com>
:
: function nullCheck()
: {
:   if (document.frm1.selInitiativeStat.selectedIndex < 1)
:   {
:     alert("Error! Error! Does not compute!");
:     return false;
:   }
: }
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

or, if you wanted to have more than one blank option in your dropdown list
to break groups of items apart, then you could do it like this:

function nullCheck()
{
  list = document.frm1.selInitiativeStat;
  if(!list.options[list.selectedIndex].value)
  {
    alert('Error! Error! Does not compute!');
    return false;
  }
}

good luck,

.jeff

name://jeff.howden
game://web.development
http://www.evolt.org/
mailto:jeff@members.evolt.org