Tuesday, July 14, 2009

Validate FCK Editor Using Custom Validator

Validate FCK Editor Using Custom Validator

In asp.net there is no direct way to validate FCKEDITOR so In order to do so we need to write a java script function which will validate FCKEDITOR on client side.

Here are the steps to make it possible:

Step1: Include following javascript function in ur html part.

< script language="javascript" type="text/javascript">
function ValidateFCK(source, args) {

var fckBody = FCKeditorAPI.GetInstance('<%=FCKeditor1.ClientID %>');
args.IsValid = fckBody.GetXHTML(true) != "";
}



Step2: Now add a asp Custom Validator in ur HTML part and call ValidateFCK function.

< asp:CustomValidator Text="" runat="server" ID="CustValDesc" ControlToValidate="FCKeditor1" ClientValidationFunction="ValidateFCK" ValidateEmptyText="True">

Thats it [:)]

No comments:

Post a Comment