【发布时间】:2011-05-27 01:36:19
【问题描述】:
我想修改下面的自定义验证器,以便它检查 RadEditor 是否不为空或者不仅包含 HTML 标签,如 br 和 p 标签等。其中必须有一些文本,而不仅仅是 HTML 标签.如何实现我想要的?
<asp:CustomValidator runat="server" ID="CustomValidator1" ControlToValidate="RadEditor1" ClientValidationFunction="checkLength">* The text length should not exceed 50 symbols.</asp:CustomValidator>
<script type="text/javascript">
var limitNum = 50;
function checkLength(sender, args)
{
//Note that sender is NOT the RadEditor. sender is the <span> of the validator.
//The content is contained in the args.Value variable
var editorText = args.Value;
args.IsValid = editorText.length < limitNum;
}
问题是当我在 RadEditor 中使用必填字段验证器时,br 标记被存储为一个值,因此验证失败。那么如何编写一个自定义验证器来检查编辑器中是否只有 html 标签??
【问题讨论】:
标签: c# javascript asp.net telerik