Sosi
Sosi

Reputation: 2578

Fck editor problem

Im using FCK Editor control instead a textarea element. I installed it without problems.

But when i want to validate it with a Custom validator of ASP.Net 2.0, im not getting the result expected.

These lines are the code that i have:

<textarea style="width:30px;height:20px;" class="ckeditor" id="txtdescription" runat="server" name="txtdescription" cols="5" rows="10"></textarea>

<asp:CustomValidator id="descval" runat="server" ControlToValidate="txtdescription" EnableClientScript="true" Enabled="true" ValidateEmptyText="true" Display="Dynamic" ClientValidationFunction="ValidateTextDesc" Text="*" ErrorMessage="*"/> 

<asp:Button ID="buttonadd" runat="server" Text="Add text" OnClick="buttonadd_Click" />

And my javascript code that executes the CustomValidator client function is:

function ValidateTextDesc(source, args)
{
    var descriptiontext = document.getElementById("txtdescription");
 if ((descriptiontext.value.indexOf("<script") != -1) || (descriptiontext.value.length==0))
 {
     args.IsValid=false;
 }
 else
 {
    args.IsValid = true;
 }
 return args.IsValid;
}

My problem is that i have to click twice my submit button to execute this Client function:

Do you know why this issue is happening? Thanks in advance. Regards. Josema.

Upvotes: 0

Views: 549

Answers (2)

Sosi
Sosi

Reputation: 2578

For the new version of CKEditor (3.0.2) the solution is to use:

CKEDITOR.instances.idoftextarea.getData();

Best Regards.

Upvotes: 1

Pekka
Pekka

Reputation: 449435

My shot in the dark is that FCKeditor is not transmitting its contents into the textarea before your validation runs.

You need to call FCKEditor's function to transmit the contents manually before you start the validation.

It should be somewhere along the lines of FCKeditorAPI.GetInstance('FCKEditorFieldName').GetHTML()

Upvotes: 1

Related Questions