Hi everybody:
I am trying to write a generic function, isValidMonth, that can used on 2
form elements, smonth and emonth. I would like the function to test whether
the user has selected a month or not.
If anyone can help me I would really appreciate it. What I have done
follows.
My form has:
<SELECT name=smonth>
<OPTION value=0>-Month-
<OPTION value=1>Jan
<OPTION value=2>Feb
<OPTION value=3>Mar
...
<OPTION value=12>Dec
</SELECT>
<SELECT name=emonth>
<OPTION value=0>-Month-
<OPTION value=1>Jan
<OPTION value=2>Feb
<OPTION value=3>Mar
...
<OPTION value=12>Dec
</SELECT>
..
My JavaScript contains:
function isValidMonth(month) {
if (month[month.selectedIndex].value == 0
return false
return true
}
function submitIt(form) {
if (!isValidmonth(smonth))
alert("You have not selected a start month")
return true
}
Thank you
Terry