Monday, February 28, 2011

Re: DateBox : Null value not identified

Sorry I submitted the incomplete query by mistake. Here's my
question:

I have to do mandatory check for a date field when the user doesn't
enter any date in the datebox input, however I'm always getting the
last set value for the date field instead of null when user doesn't
enter any data.

Kindly help.


My code:
final DateBox dateBox = new DateBox();
dateBox.setValue(new Date());
dateBox.setFormat(new
DateBox.DefaultFormat(DateTimeFormat.getFormat("ddMMMyy")));


//capture the change event of date picker
dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() {
@Override
public void onValueChange(final ValueChangeEvent<Date> event)
{
if (event.getValue() == null) {
Window.alert("Date cannot be null");
}
}
}

Window.alert("Date : " +dateBox.getValue() );


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment