jQuery日历放在第二个调用“false”表示! 即在第一个“Von”(从)字段中单击用户,正确调用日历。 如果用户单击“Bis”(to)字段,则会正确调用日历。 但是用户点击抵制日历上的“Von”(来自)字段被错误地调用,用户可以无限制地调用日历的“未来”滚动!
这里集成了源代码:
<script>
$(function() {
$(function() {
$( "#date_Von" ).datepicker({
dateFormat: 'dd.mm.yy',
changeMonth: true,
changeYear: true,
numberOfMonths: 3,
dayNamesMin: [ "So","Mo", "Di", "Mi", "Do", "Fr", "Sa" ],
monthNamesShort: [ "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" ],
monthNames: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
maxDate: "+0d",
minDate: new Date(2007, 1 - 1, 1),
prevText: "Zurück",
nextText: "Weiter",
onClose: function( selectedDate ) {
$( "#date_Bis" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#date_Bis" ).datepicker({
dateFormat: 'dd.mm.yy',
changeMonth: true,
changeYear: true,
numberOfMonths: 3,
dayNamesMin: [ "So","Mo", "Di", "Mi", "Do", "Fr", "Sa" ],
monthNamesShort: [ "Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" ],
monthNames: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
maxDate: "+0d",
minDate: new Date(2007, 1 - 1, 1),
prevText: "Zurück",
nextText: "Weiter",
onClose: function( selectedDate ) {
$( "#date_Von" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
});
</script>
有谁知道为什么会这样?
答案 0 :(得分:0)
问题是当你关闭第二个日期选择器而没有选择日期时,maxDate被设置为空白,有效地从第一个字段中删除了验证。
因此,一种可能的解决方案是使用onSelect事件
b.jsp
如果要使用关闭处理程序本身,则如果日期为空,则设置默认约束值
<%!
Connection connection = null;
Statement statement = null;
%>
<%
try {
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test", "postgres", "root");
statement = connection.createStatement();
} catch (Exception e) {
out.println(e.getMessage());
}
%>
<%!
public List select(String query) {
List rows = new ArrayList();
Map row = null;
try {
ResultSet resultSet = statement.executeQuery(query);
ResultSetMetaData metaData = resultSet.getMetaData();
int numColumns = metaData.getColumnCount();
while (resultSet.next()) {
row = new HashMap();
for (int i = 1; i < numColumns + 1; i++) {
row.put(metaData.getColumnName(i), resultSet.getObject(i));
}
rows.add(row);
}
resultSet.close();
} catch (Exception e) {
}
return rows;
}
%>