Hi All,
I am facing problems with client side validation of RadEditor.
I want to put a check on length of the string entered in editor.
Following is the code, I have written:
To put check on length, I used function get_html() and get_text(). But length of string returned by these function is sometimes smaller than length of server side attribute "Content".
Then I found online demo(http://demos.telerik.com/aspnet-ajax/editor/examples/validators/defaultcs.aspx) which had implementation like function "ValidateEditor1". But that also returned smaller length.
I observed that this problem consistently occurs with strings spanning over multiple lines. You can try this by entering any multi-line string in the editor.
So I think I will be able to solve this problem if I find some api on client side, which returns string exactly equal to the one returned by server side attribute "Content". Can anyone provide more insight into this problem?
Regards
Shrikant
I am facing problems with client side validation of RadEditor.
I want to put a check on length of the string entered in editor.
Following is the code, I have written:
========ASPX======== |
<html xmlns="http://www.w3.org/1999/xhtml" > |
<head runat="server"> |
<title></title> |
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1"> |
<script type="text/javascript" language="javascript"> |
function ValidateEditor() |
{ alert($find("<%=editor1.ClientID %>").get_text().length); |
alert($find("<%=editor1.ClientID %>").get_html().length); |
alert($find("<%=editor1.ClientID %>").get_html(true).length); |
} |
function ValidateEditor1(sender, args) |
{ |
alert("args.Value.length = "+args.Value.length); |
} |
</script> |
</telerik:RadScriptBlock> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<asp:CustomValidator ID="val1" Display="None" runat="server" ClientValidationFunction="ValidateEditor" |
ValidationGroup="group1"></asp:CustomValidator> |
<asp:CustomValidator ID="CustomValidator1" Display="None" runat="server" ClientValidationFunction="ValidateEditor1" |
ValidationGroup="group1" ControlToValidate="editor1"></asp:CustomValidator> |
<telerik:RadEditor ID="editor1" runat="server" Width="400" Height="100" |
Skin="Vista" EditModes="Design"> |
<Tools> |
<telerik:EditorToolGroup> |
<telerik:EditorTool Name="Bold" /> |
<telerik:EditorTool Name="Italic" /> |
<telerik:EditorTool Name="Underline" /> |
<telerik:EditorTool Name="InsertOrderedList" /> |
<telerik:EditorTool Name="InsertUnorderedList" /> |
<telerik:EditorTool Name="Indent" /> |
<telerik:EditorTool Name="Outdent" /> |
<telerik:EditorTool Name="JustifyLeft" /> |
<telerik:EditorTool Name="JustifyCenter" /> |
<telerik:EditorTool Name="JustifyRight" /> |
</telerik:EditorToolGroup> |
</Tools> |
</telerik:RadEditor> |
<asp:Button Text="SAVE" ID="button16" OnClick="Save_Click" |
runat="server" ValidationGroup="group1" /> |
</div> |
</form> |
</body> |
========CODE BEHIND======== |
public partial class EditorValidation : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
} |
protected void Save_Click(object sender, EventArgs e) |
{ |
int len = editor1.Content.Length; |
} |
} |
To put check on length, I used function get_html() and get_text(). But length of string returned by these function is sometimes smaller than length of server side attribute "Content".
Then I found online demo(http://demos.telerik.com/aspnet-ajax/editor/examples/validators/defaultcs.aspx) which had implementation like function "ValidateEditor1". But that also returned smaller length.
I observed that this problem consistently occurs with strings spanning over multiple lines. You can try this by entering any multi-line string in the editor.
So I think I will be able to solve this problem if I find some api on client side, which returns string exactly equal to the one returned by server side attribute "Content". Can anyone provide more insight into this problem?
Regards
Shrikant