Wednesday, February 3, 2016

Use a asp:RegularExpressionValidator in web forms to keep users from passing in the angle brackets.

The regular expression here allows, letters, numbers, spaces, apostrophes, hyphens, periods, question marks, and exclamation marks:

<asp:RegularExpressionValidator ID="EmailTemplateRegularExpressionValidator"
      runat="server" ControlToValidate="EmailTemplate" Display="Dynamic"
      ErrorMessage="Please enter standard characters."
      ValidationExpression="([a-z]*[A-Z]*[0-9]*[\.]*[\s]*[\']*[?]*[!]*[-]*)*">
</asp:RegularExpressionValidator>

No comments:

Post a Comment