Thursday, 5 January 2012

Restrict Script in the Textbox(Regular Expression) in SharePoint webpart or Asp.net Pages



Add regular expression to the text box.


   <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Width="99%"
                Height="50px"></asp:TextBox>
            <asp:RequiredFieldValidator ID="rfvdescription" runat="server" ErrorMessage="Enter the Description" Display="Dynamic"
                ControlToValidate="txtdescription" ValidationGroup="submit"></asp:RequiredFieldValidator>
                  <asp:RegularExpressionValidator ID="revDescription" runat="server" ControlToValidate="txtDescription"
                     ErrorMessage="Enter 1000 characters or less These ^<>`~!@\}%;_^{* characters Not allowed."
                    ValidationExpression="^[^<>`~!@\}%;_^{*]{0,1000}$"></asp:RegularExpressionValidator>

No comments:

Post a comment