textarea 要素の代わりに FCK Editor コントロールを使用しています。問題なくインストールできました。
しかし、ASP.Net 2.0 のカスタム バリデータで検証したい場合、期待どおりの結果が得られません。
これらの行は、私が持っているコードです:
<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" />
CustomValidator クライアント関数を実行する私の JavaScript コードは次のとおりです。
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;
}
私の問題は、このクライアント関数を実行するために送信ボタンを 2 回クリックする必要があることです。
なぜこの問題が起こっているのか知っていますか?前もって感謝します。よろしく。ホセマ。