开发者

setEndDate() in smartgwt

开发者 https://www.devze.com 2023-03-06 12:43 出处:网络
I have a requirement to prevent the user from selecting date which is greater than current date. I tried to enforce it by setting setEndDate(new Date()) but it didn\'t work.

I have a requirement to prevent the user from selecting date which is greater than current date. I tried to enforce it by setting setEndDate(new Date()) but it didn't work.

DateItem dateItem = new DateItem();  

dateItem.setTitle("Date"); 
dateItem.setName("dateValue");
dateItem.setUseTextField(true);

TextItem textItem = new TextItem();
textItem.setAttribute("readOnly", true);

dateIte开发者_JAVA技巧m.setAttribute("textFieldProperties", textItem); 
dateItem.setDisabled(true);
dateItem.setRequiredMessage("Please select a valid Date");
dateItem.setEndDate(new Date());

Even now I am able to select dates 19/5/2011, 20/5/2011 and so on.


Well according to the documentation, dateItem.setStartDate() or dateItem.setEndDate() does not prevent the user to select an invalid date. You may read it from here.

Hope this helps you.


You can do an event onchanged which puts the current date instead of whatever the user wrote in the date field if he entered a greater date.

0

精彩评论

暂无评论...
验证码 换一张
取 消