Hi.
I'm trying to use the Editor together with a CustomValidator (the CustomValidator's attribute ClientValidationFunction="ValidateContent", see the javascript function below). I want to check if the user has written some content into the editor before he submits the forms.
The validation works as long as the Editor is in Design Mode when the submit button is clicked. But when the editor in in HTML Mode or Preview Mode when the submit button is clicked, the form submits no matter what the content is in the Editor. It seems like the validator will not work when the Editor is in HTML Mode or Preview Mode: When the editor is in one of these two modes, not even the line alert(content.getHtml()); is called.
My javascript code running with the CustomValidator:
Code: JavaScript
function ValidateContent(oSrc, args)
{
var content = eo_GetObject('" + txtContent.ClientID + @"');
alert(content.getHtml()); // just to check if the function is called
if (content.getHtml().trim() == '' || content.getHtml().trim() == '<p> </p>')
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
Is this a bug, or am I doing something wrong when I want to validate that the Editor has some content?
What is the best way to validate the input of the Editor no matter in which mode the Editor is when the form is submitted?
HT