Today I spent kind of 30 minutes to do something stupid, but worth to share! Maybe I can save your time Googling for it.
Validate a FCKEditor object in client side is really simple and you need to use the FCKEditor Javascript API.
Here is the code of my .aspx file
<
fck:FCKeditor ID="txtWinnerpage" runat="server" Value='' BasePath="~/fckeditor/" EditorAreaCSS="/css/editor.css" Width="680px" Height="500px" /><
asp:CustomValidator ID="CustomValidator2" runat="server" ValidationGroup="Tab4" ValidateEmptyText="true" ControlToValidate="txtWinnerpage" ErrorMessage="This is a required field" ClientValidationFunction="cvWinner" Display="Dynamic" ><
/asp:CustomValidator>Don't forget to include the property ValidateEmptyText="true" in the CustomValidator control. You can also see that I set the property ClientValidationFunction, this is the name of the JavaScript function the control will call.
Here is the JavaScript code
<
script type="text/javascript">function cvWinner(sender, args) {
var fckBody = FCKeditorAPI.GetInstance('<%=txtWinnerpage.ClientID %>');
args.IsValid = fckBody.GetXHTML(true) != "
";
}
<
/script>