我有一个需要验证 DateFrom 和 DateTo 的表单。
我已经这样做了:
// start date
RequiredTextField<Date> startdateField =
new RequiredTextField<Date>("startDate", Date.class);
startdateField.add(new DatePicker(){
@Override
protected CharSequence getIconUrl() {
return RequestCycle.get().getUrlRenderer().renderContextPathRelativeUrl("/image/date-picker.png");
}
});
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE,-1);
startdateField.add(DateValidator.minimum(cal.getTime()));
// end date
RequiredTextField<Date> enddateField = new RequiredTextField<Date>("endDate", Date.class);
enddateField.add(new DatePicker(){
@Override
protected CharSequence getIconUrl() {
return RequestCycle.get().getUrlRenderer().renderContextPathRelativeUrl("/image/date-picker.png");
}
});
// enddateField.add(DateValidator.minimum(startdateField.getModel().getObject()));
// this does not work . Form submitted ?
现在我如何放置一个验证器,说明 endDate 必须等于或大于检票口中选择的开始日期?
任何的想法?帮助表示赞赏。