FCK是否为空的验证问题

用的RequiredFieldValidator来验证Fckeditor的内容是否为空,结果添加的时候发现第一次提交他会提示为空,要再点一次才能提交。

下面是解决方法:
<script language="javascript"  type="text/javascript">
var oEditer;
function CustomValidate(source, arguments)
{
    var value = oEditer.GetXHTML(true);
    if(value=="")
    {
      arguments.IsValid = false;
    }
  else
  {
      arguments.IsValid = true;
    }
}

function FCKeditor_OnComplete( editorInstance )
{
    oEditer = editorInstance;
}
</script>

把上面的脚本添加至页面内,然后选用CustomValidator验证控件,设置ClientValidationFunction="CustomValidate",并设置ValidateEmptyText属性为True,还有记得设置ControlToValidate啊。
posted @ 2009-02-20 16:25  Devil_Zhang  阅读(429)  评论(1编辑  收藏  举报