Actually in CustomerInfo and CustomerRegister BirthDate field is not requred, and you can insert a wrong date like this
31-02-1985 .-----but february 31 dont' exist.
So i try to add a RequiredFieldValidator and a compareFieldValidator to type check the date.
But they don't work because, i think nopdatePiker not support validators!
So i fix the code of NopDatePiker (nopCommerce_1.90_Source\Libraries\Nop.Controls) to allow validators
How to....
- open nopCommerce_1.90_Source\Libraries\Nop.Controls\Nop.Controls.csproj with visual sutdio or visual c# express
- open nopDatePiker
- add this code ( only bold code)
/// </summary>
[ValidationProperty("Text")]
public partial class NopDatePicker : Control, INamingContainer
{
.........
public String Text{
get
{
if (this.SelectedDate != null)
{
return this.SelectedDate.Value.ToShortDateString();
}
return "";
}
}
in this way validation works using Text property ( wrong date euals empty so 31/02/1985 result invalid
also non selected date result invalid )
Now you have to add the required field validatror
this is a working example for customer info
<nopCommerce:NopDatePicker runat="server" ID="dtDateOfBirth" DayText="<% $NopResources:DatePicker2.Day %>"
MonthText="<% $NopResources:DatePicker2.Month %>" YearText="<% $NopResources:DatePicker2.Year %>" />
<asp:RequiredFieldValidator ID="rfvDateOfBirth" ControlToValidate="dtDateOfBirth" ValidationGroup="CustomerInfo" runat="server" ErrorMessage="error message" ToolTip="errormessage" >*</asp:RequiredFieldValidator>
Hope this help