| 1 | <%@ Page Language="C#" AutoEventWireup="true"%> |
|---|
| 2 | |
|---|
| 3 | <%@ Register assembly="CKEditor.NET" namespace="CKEditor.NET" tagprefix="CKEditor" %> |
|---|
| 4 | |
|---|
| 5 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 6 | <script runat="server"> |
|---|
| 7 | |
|---|
| 8 | void ServerValidateCKEditor1(object source, ServerValidateEventArgs args) |
|---|
| 9 | { |
|---|
| 10 | try |
|---|
| 11 | { |
|---|
| 12 | args.IsValid = args.Value.Contains("c"); |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | catch (Exception ex) |
|---|
| 16 | { |
|---|
| 17 | args.IsValid = false; |
|---|
| 18 | } |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | </script> |
|---|
| 22 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 23 | <head runat="server"> |
|---|
| 24 | <title></title> |
|---|
| 25 | <script type="text/javascript"> |
|---|
| 26 | function ClientValidateCKEditor1(sender, args) { |
|---|
| 27 | |
|---|
| 28 | console.log(args.Value); |
|---|
| 29 | // Not valid if "b" letter was not entered |
|---|
| 30 | if (!args.Value.trim().match(/b/)) { |
|---|
| 31 | args.IsValid = false; |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | </script> |
|---|
| 35 | </head> |
|---|
| 36 | <body> |
|---|
| 37 | <form id="form1" runat="server"> |
|---|
| 38 | <div> |
|---|
| 39 | |
|---|
| 40 | <CKEditor:CKEditorControl ID="CKEditorControl1" runat="server" Text=""> |
|---|
| 41 | </CKEditor:CKEditorControl> |
|---|
| 42 | <asp:CustomValidator ID="val1" runat="server" ErrorMessage="Please Enter Text with letters b and c." ClientValidationFunction="ClientValidateCKEditor1" ControlToValidate="CKEditorControl1" ValidateEmptyText="true" OnServerValidate="ServerValidateCKEditor1" ></asp:CustomValidator> |
|---|
| 43 | <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="This field is required." ControlToValidate="CKEditorControl1"></asp:RequiredFieldValidator> |
|---|
| 44 | <asp:Button ID="Button1" runat="server" Text="Button" /> |
|---|
| 45 | |
|---|
| 46 | </div> |
|---|
| 47 | </form> |
|---|
| 48 | </body> |
|---|
| 49 | </html> |
|---|