SharePoint DateTimeControl is nice to use as it gives the similar look and feel experience on the SharePoint list. Since it does not have a built in validator, we can use the asp.net validator to validate it.
It won’t works by setting the validator ControlToValidate property to the DateTimeControl id. This is because the DateTimeControl is just a calendar drop down and a textbox(We want to validate against this textbox).
I found out SharePoint is actually giving an ID to the textbox programmatically in this format:
So, this is a simple example how it works:
<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <spuc:DateTimeControl runat="server" ID="dtc_statusUpdateTime" /> <asp:RequiredFieldValidator ID="val_dtc_statusUpdateTime" runat="server"ControlToValidate="dtc_statusUpdateTime$dtc_statusUpdateTimeDate" ErrorMessage="Please enter the Update Time"/>