Disable Key press on SharePoint:DateTimeControl

Sharepoint DateTime control is placed in a Webpart or Application Page. We need to allow the users to select the Date from the Date Picker ICON in the DateTime Control to avoid the typing in the DateTime Control TextBox.

Here you go for the solution :

In Code behind :

((TextBox)(dtpClearfrmCustoms.Controls[0])).Attributes.Add("readonly", "readOnly");

In Source Page :

<SharePoint:DateTimeControl ID="dtpClearfrmCustoms" runat="server" DateOnly="true"
                        LocaleId="2057" />


JavaScript validation for SharePoint DateTime Control

if (document.getElementById('<%= dtpClearfrmCustoms.Controls[0].ClientID  %>').value == "") {
  alert("Please select the date");
                return false;

    }


Hope this would helps you....


Comments

Popular posts from this blog

This content database has a schema version which is not supported in this farm

Export all documents/Folders permissions to CSV using SharePoint PowerShell

SPUtility.js