I'm trying to enforce a date range logic on two DateFields. the OnValueChange event for each, sets the min and max values the DateField can have. Simply put, DateField FROM's onValueChange event would set DateField TO's minValue to whatever FROM's value is. Vice versa for TO's onValueChange would set the FROM's maxValue.
The problem I'm coming up with is that both DateFields can't be the same value, I get a validation error. How do I make it so that the TO value is ">=" the minValue and the FROM value is "<=" the maxValue?
Please let me know if you need more clarification.
Code:
final DateField fromValue = new DateField();
fromValue.addValidator( new EmptyValidator<Date>() );
final DateField toValue = new DateField();
toValue.addValidator( new EmptyValidator<Date>() );
fromValue.addValueChangeHandler( new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
toValue.setMinValue( event.getValue() );
}
});
toValue.addValueChangeHandler( new ValueChangeHandler<Date>() {
@Override
public void onValueChange(ValueChangeEvent<Date> event) {
fromValue.setMaxValue( event.getValue() );
}
});
when inspecting your MinDateValidator for your DateField, I noticed that you use Date.before() function, so it doesn't really allow for "same" date validity.