伙计们,以下代码允许用户选择9月1日到当前日期之间的日期。我在使用jQuery datepicker代码时遇到问题。请告诉我您的意见。
> <%try {sdf = new SimpleDateFormat(“ yyyyMMdd”); > > > minDate = new Date(); // timestamp > now > Calendar cal = Calendar.getInstance(); // get > calendar instance > cal.setTime(minDate); // set cal > to date > cal.set(cal.get(cal.YEAR),cal.SEPTEMBER,1); > minDate = cal.getTime(); > > maxDate = new Date(); > cal.setTime(maxDate); > maxDate = cal.getTime(); > } catch (Exception e) > { > > System.out.println(e); > } > %> > <script type="text/javascript"> > var mx = <%=sdf.format(minDate)%>; > var mv = <%=sdf.format(maxDate)%>; > $(document).ready(function(){ > $("#revRepDate").datepicker({ > showOn: 'button', buttonImageOnly: > true, buttonImage: > 'style/images/icon_cal.png', > dateFormat: 'yymmdd' }); > }); $("#revRepDate").datepicker('option',{minDate:mx > , maxDate:mv }); >
您需要引号:
var mx = '<%=sdf.format(minDate)%>'; var mv = '<%=sdf.format(maxDate)%>';