2010-12-17 4 views
0

RadEditorが空でないことをチェックするようにカスタムバリデーターを変更するか、brやpタグなどのHTMLタグが含まれているだけではありません。ちょうど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タグしか持たないことをチェックするカスタムバリデータを書くにはどうしたらいいですか? jQueryのを使用して

答えて

1

それは、このような単純なのです:

args.IsValid = $(editorText).text().length < limitNum; 

のjQueryのtext方法は、すべてのタグを削除し、唯一の「純粋なテキスト」であなたを残します。

+0

お試しください..thnx – Serenity