SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my SharePoint 2010 visual web part, I have two SharePoint DateTime Picker controls which is used to add new appointment to the appointment schedule calendar.

Here, one datetime picker control is for AppointmentStart and other for AppointmentEnd. I need to check if there is already appointment existing for the selected period.

I need to validate the date and time selected in the selected changed event. I could get OnDateChanged event at server side but here i couldn't validate the time part. How can this be done?

share|improve this question

Since its a visual webpart you can use .Net and JavaScript together to validate your DateTime Pickers controls, check this link out,



Can you provide the code your using at the moment for validation for DateTime picker control as I think you can validate it using onDateChanged Server side event can't you.

Hope it helps :)

share|improve this answer

you can try the below code:

<SharePoint:DateTimeControl ID="dtFrom" runat="server" DateOnly="true" IsRequiredField="true"/>            
<asp:CompareValidator ID="CompareValidator1" runat="server" 
    ControlToValidate="dtFrom$dtFromDate" Type="Date" Operator="DataTypeCheck" ErrorMessage="Please enter valid date." Display="Dynamic"></asp:CompareValidator>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.