I have a form that needs validating using DOM methods and javascript for our web class. I have validated all name, address, email, etc. fields. I have validated the given credit card number using a modulus algorithm. Our next task is to validate the given date (month, year) that is given via a standard option box on the html file. I understand how to retrieve the year (as it will be returned as an integer), however, was curious as to the most efficient way to retrieve and convert the Month into an int. The month is in standard form:
<label for="month">Month:</label>
<select id="month" name="month" disabled="true">
<option value="0">January</option>
<option value="1">Febuary</option>
<option value="2">March</option>
<option value="3">April</option>
<option value="4">May</option>
<option value="5">June</option>
<option value="6">July</option>
<option value="7">August</option>
<option value="8">September</option>
<option value="9">October</option>
<option value="10">November</option>
<option value="11">December</option>
</select>
Easy enough to get the month as a string, but is there some way to get the number back directly using document.getElementById('month') but somehow tagging it with option value +1 so it directly returns the int? Or do I have to do it long hand in the function, ie
January = 1; February=2; etc.?
Thanks for any help.