调试需加入jquery文件
<script> <BR>$(function(){ <BR>$('#year').change(function(){ <BR>if (ifLeapYear($(this).val())) <BR>{ <BR>if ($('#month').val() == 2 && $('#day').children().length == 29) <BR>{ <BR>$('#day').append('<option value="29">29'); <BR>} <BR>} else <BR>{ <BR>if ($('#month').val() == 2 && $('#day').children().length == 30) <BR>{ <BR>$('#day :last-child').remove(); <BR>} <BR>} <BR>}); <br><br>$('#month').change(function(){ <BR>var thisValue = $(this).val(); <BR>var dayValue = $('#day').val(); <BR>var month1 = ['4','6','9','11']; <BR>$('#day').html('<option value="">-请选择-'); <BR>var day = ''; <BR>if (thisValue == '') <BR>{ <BR>return false; <BR>} <BR>if ($.inArray(thisValue, month1) != -1) <BR>{ <BR>day = setDay(30); <BR>$('#day').append(day); <BR>} else if ($(this).val() == '2') <BR>{ <BR>if ($('#year').val() != '' && ifLeapYear($('#year').val())) <BR>{ <BR>day = setDay(29); <BR>} else <BR>{ <BR>day = setDay(28); <BR>} <BR>$('#day').append(day); <BR>} else <BR>{ <BR>day = setDay(31); <BR>$('#day').append(day); <BR>} <BR>$('#day').find('option[value='+dayValue+']').attr('selected',true); <BR>}); <BR>}) <BR>function setDay(day) <BR>{ <BR>var dayInfo = ''; <BR>for (var i=1; i<=day; i++) <BR>{ <BR>dayInfo += '<option value="' + i +'">' + i+ ''; <BR>} <BR>return dayInfo; <BR>} <BR>function ifLeapYear(year) <BR>{ <BR>if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) <BR>{ <BR>return true; <BR>} else <BR>{ <BR>return false; <BR>} <BR>} <BR></script>
年
月
日