The point is that you showed me just the MetaDataType...so I don't know too much of your model. Does your ExpiryDate is a DateTime? ie a nullable DateTime ?
In such a case you have to furnish a default date to be used as initial date when the Date is null as shown below:
Obviously you can set emptyDate to whatever you like not necessaruly to DateTime.Now.
Don't forget to include also the js and css files needed by the jQuery datepicker. Finally, either you render the StorageDate in yiour page with a DateTimeInput, or apply to it the Milestone attribute as you have done with the Today property.
francesco ab...
All-Star
20912 Points
3279 Posts
Re: Custom DateTime Validation for MVC 3 unobtrusive client side validation
Oct 20, 2011 06:59 AM|LINK
The point is that you showed me just the MetaDataType...so I don't know too much of your model. Does your ExpiryDate is a DateTime? ie a nullable DateTime ?
In such a case you have to furnish a default date to be used as initial date when the Date is null as shown below:
@{var DT = Html.DateTimeFor(m => m.ExpiryDate, dateInCalendar : true, emptyDate: DateTime.Now);}
Obviously you can set emptyDate to whatever you like not necessaruly to DateTime.Now.
Don't forget to include also the js and css files needed by the jQuery datepicker. Finally, either you render the StorageDate in yiour page with a DateTimeInput, or apply to it the Milestone attribute as you have done with the Today property.
Mvc Controls Toolkit | Data Moving Plug-in Videos