Hi, after some days testing and working on an issue I really hope to find some helping information here. I would like to validate a name in SharePoint’s newdocset.aspx. Despite the fact there is already a validation performed, I need to validate more precise and for additional special characters to be avoided, especially since the name of the doc set will be used later for a path, which will not work if there is a point used in this name field. In the initial validation a point can be used which I need to suppress.
Therefore I was about to use JavaScript in the past with the PreSaveAction () function. However, this was not working; it seems this function will not execute prior to “save” the page. So every code written within the function seems to be ignored.
Lately I have tried another way. Based on the JavaScript experience I would like to validate the user input on server side. I have added some lines (see below) to maintain a simple validation in a TestTextBox to make sure the validation is working… which is the case.
In my opinion, the next step would be to identify the ID of the initial “Name” field to perform the validation in this box, however, I was not able to identify the “name” ID in the original code. Currently I am a bit frustrated and confused, since it seems there is a function which could make my life easier, but I don’t find the way to implement it at the right spot.
If you have an idea to find the right identification or to make sure to validate the right string, I am looking forward to read from you. Even if you are convinced I am going the wrong way, please let me know which solution you would propose to have a simple and maybe stable result.
Thanks a lot in advance!
Therefore I was about to use JavaScript in the past with the PreSaveAction () function. However, this was not working; it seems this function will not execute prior to “save” the page. So every code written within the function seems to be ignored.
Lately I have tried another way. Based on the JavaScript experience I would like to validate the user input on server side. I have added some lines (see below) to maintain a simple validation in a TestTextBox to make sure the validation is working… which is the case.
In my opinion, the next step would be to identify the ID of the initial “Name” field to perform the validation in this box, however, I was not able to identify the “name” ID in the original code. Currently I am a bit frustrated and confused, since it seems there is a function which could make my life easier, but I don’t find the way to implement it at the right spot.
If you have an idea to find the right identification or to make sure to validate the right string, I am looking forward to read from you. Even if you are convinced I am going the wrong way, please let me know which solution you would propose to have a simple and maybe stable result.
Thanks a lot in advance!
Code:
<%-- _lcid="1033" _version="15.0.4420" _dal="1" --%><%-- _LocalBinding --%><%@ Assembly Name="Microsoft.Office.DocumentManagement.Pages, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%><%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%><%@ Page Language="C#" DynamicMasterPageFile="~masterurl/default.master" Inherits="Microsoft.Office.DocumentManagement.Pages.NewDocSet" %><%@ Import Namespace="Microsoft.SharePoint.WebControls" %><%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Import Namespace="Microsoft.SharePoint" %><%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register TagPrefix="wssuc" TagName="LinksTable" src="/_controltemplates/15/LinksTable.ascx" %><%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="/_controltemplates/15/InputFormSection.ascx" %><%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="/_controltemplates/15/InputFormControl.ascx" %><%@ Register TagPrefix="wssuc" TagName="LinkSection" src="/_controltemplates/15/LinkSection.ascx" %><%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="/_controltemplates/15/ButtonSection.ascx" %><%@ Register TagPrefix="wssuc" TagName="ActionBar" src="/_controltemplates/15/ActionBar.ascx" %><%@ Register TagPrefix="wssuc" TagName="ToolBar" src="/_controltemplates/15/ToolBar.ascx" %><%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="/_controltemplates/15/ToolBarButton.ascx" %><%@ Register TagPrefix="wssuc" TagName="Welcome" src="/_controltemplates/15/Welcome.ascx" %><%@ Register Tagprefix="wssawc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><asp:Content contentplaceholderid="PlaceHolderPageTitle" runat="server">
<%@ Register TagPrefix="spuc" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><asp:Literal id="dlgTitleLiteral" runat="server"/></asp:Content>
<asp:Content contentplaceholderid="PlaceHolderPageTitleInTitleArea" runat="server">
<asp:Literal id="windowTitleLiteral" runat="server"/>
</asp:Content>
<asp:Content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:cssregistration name="forms.css" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
<SharePoint:sppagestatussetter id="PageStatus" runat="server"/>
<wssawc:inputformcustomvalidator runat="server"
id="ExistingDocSetValidator"
EnableClientScript ="true"
OnServerValidate = "ExistingDocumentSetValidation"
CssClass="ms-core-form-error ms-formvalidation"
/>
<asp:PlaceHolder runat="server" id="ListFormWebPartPlaceHolder"/>
<wssuc:ButtonSection runat="server">
<Template_Buttons>
<asp:button class="ms-ButtonHeightWidth" runat="server" text="<%$Resources:wss,multipages_savebutton_text%>" onclick="OKBtn_Click" id="btnOK" />
</Template_Buttons>
</wssuc:ButtonSection>
<SharePoint:pagerendermode runat="server" RenderModeType="Standard" />
<wssawc:inputformtextbox ID="TestTextBoxName" runat="server" class="ms-long" Title="Name" />
<wssawc:inputformregularexpressionvalidator ID="Validator" runat="server" Display="Dynamic" SetFocusOnError="true"
ControlToValidate="TestTextBoxName"
ValidationExpression="^[A-Za-z0-9_-]$"
ErrorMessage="spcl char not allowed" />
</asp:Content>