[thelist] javascript gurus...help!
Joshua OIson
joshua at alphashop.net
Mon Mar 26 14:42:02 CST 2001
You may try something like this
<script>
function validate()
{
if (document.forms['myform'].elements['text1'].value.length)
{
// text1 has something in it
if (document.forms['myform'].elements['select1'].selectedIndex == 0)
{
alert('You must pick an option if you\'ve typed text');
return false;
}
}
return true;
}
</script>
<form onsubmit="return validate()" name="myform">
<input type="text" name="text1">
<select name="select1">
<option value="">Pick one</option>
<option value="1">opt 1</option>
</select>
<input type="submit">
</form>
----- Original Message -----
From: "Liz" <liz at tufts.edu>
Subject: [thelist] javascript gurus...help!
> Hi,
> Is there anyway to do this quick and dirty?
>
> In an html form
>
> IF the textbox is filled in with text
>
> THEN the dropdown menu becomes a required field
>
>
> thanks,
> Liz
More information about the thelist
mailing list