Validate date and time in sharepoint datetime picker control RRS feed

  • Question

  • 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?
    Saturday, October 20, 2012 7:24 AM



    Hi sujanr,

    This can’t be achieve in your code behind. Because the control is sealed. So, you should captured the time changed by Jquery.



    function TimeHasChanged() {
      alert('welcome in this new day and age');
    var MyHourField = $('#'+MyDateField.attr('id')+'Hours');
    var MyMinuteField = $('#'+MyDateField.attr('id')+'Minutes');
    MyDateField.bind('change', TimeHasChanged);
    MyMinuteField.bind('change', TimeHasChanged);
    MyHourField.bind('change', TimeHasChanged);

    More about please refer to the following link.





    • Marked as answer by Jack-Gao Friday, November 2, 2012 10:57 AM
    Tuesday, October 23, 2012 5:18 AM