asp.net 控件驗證 FCKeditor
更新時間:2009年06月19日 23:32:24 作者:
FCKEditor是一個很不錯的在線編輯器,可稱得上完美,但是它有一個問題,就是在使用RequiredFieldValidator進行驗證的時候,即使內容不為空,也需要點擊兩次才能完成
經(jīng)過查找網(wǎng)上的資料,發(fā)現(xiàn)好像是它本身的一個問題,原文如下:
With ASP.Net, I need to submit twice when using the RequiredFieldValidator in a FCKeditor instance
FCKeditor will not work properly with the Required Field Validator when the "EnableClientScript" property of the validator is set to "true" (default). Due to a limitation in the default validation system, you must set it to "false".
If you want to do client side validation, you must use a Custom Validator instead and provide the appropriate validation function, using the FCKeditor JavaScript API.
譯文如下(翻譯的不好,大家能看懂就好):
問:為什么在使用ASP.NET的RequiredFieldValidator時,我需要提交兩次
答:當RequiredFieldValidator的EnableClientScript屬性被設置成true時,F(xiàn)CKEditor不能很好的支持RequiredFieldValidator,為了解除這個限制,你必須把這個屬性設置成為false 如果你希望使用客戶端驗證,你必須使用Custom Validator制作一個非空驗證來替換RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。
看了這篇文章,我就去找FCKeditor JavaScript API的文檔,發(fā)現(xiàn)它為客戶端JavaScript的調用提供了一些屬性和方法,于是乎,就按上述的回答寫了一段JavaScript腳本來完成了驗證。
詳細解決方法:首先添加Javascript腳本:
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",否則不起作用!
這樣,再試試,OK,一次就可以直接提交了,不會出現(xiàn)提交兩次的bug了
With ASP.Net, I need to submit twice when using the RequiredFieldValidator in a FCKeditor instance
FCKeditor will not work properly with the Required Field Validator when the "EnableClientScript" property of the validator is set to "true" (default). Due to a limitation in the default validation system, you must set it to "false".
If you want to do client side validation, you must use a Custom Validator instead and provide the appropriate validation function, using the FCKeditor JavaScript API.
譯文如下(翻譯的不好,大家能看懂就好):
問:為什么在使用ASP.NET的RequiredFieldValidator時,我需要提交兩次
答:當RequiredFieldValidator的EnableClientScript屬性被設置成true時,F(xiàn)CKEditor不能很好的支持RequiredFieldValidator,為了解除這個限制,你必須把這個屬性設置成為false 如果你希望使用客戶端驗證,你必須使用Custom Validator制作一個非空驗證來替換RequiredFieldValidator,在其中使用FCKeditor JavaScript API即可。
看了這篇文章,我就去找FCKeditor JavaScript API的文檔,發(fā)現(xiàn)它為客戶端JavaScript的調用提供了一些屬性和方法,于是乎,就按上述的回答寫了一段JavaScript腳本來完成了驗證。
詳細解決方法:首先添加Javascript腳本:
復制代碼 代碼如下:
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",否則不起作用!
這樣,再試試,OK,一次就可以直接提交了,不會出現(xiàn)提交兩次的bug了
相關文章
asp.net靜態(tài)方法彈出對話框實現(xiàn)思路
為菜鳥所準備……其實就是彈出JavaScript小窗口,總得來說就是定義的一個DIV,感興趣的朋友可以了解下,或許對你學習asp.net有所幫助2013-02-02.Net中導出數(shù)據(jù)到Excel(asp.net和winform程序中)
.Net中導出數(shù)據(jù)到Excel包括以下兩種情況:asp.net中導出Excel的方法/winForm中導出Excel的方法,針對以上兩種情況做了下詳細的實現(xiàn)代碼,感興趣的朋友可不要錯過了哈,希望本文對你有所幫助2013-02-02asp.net中C#獲取字符串中漢字的個數(shù)的具體實現(xiàn)方法
獲取字符串中漢字原理是判斷漢字編碼然后進行判斷是漢字還是數(shù)字了,還有就是利用正則表達式,同樣是以漢字ascii為標準來獲取2014-02-02ASP.NET 網(wǎng)站開發(fā)中常用到的廣告效果代碼
在ASP.NET項目開發(fā)中,會被要求添加廣告,有翻屏效果、有廣告輪流顯示、飄浮廣告、左側廣告、右側廣告等。2010-04-04MongoDB.Net工具庫MongoRepository使用方法詳解
這篇文章主要為大家詳細介紹了MongoDB.Net工具庫MongoRepository的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-01-01CheckBox為CheckBoxList實現(xiàn)全選或全取消選擇(js代碼實現(xiàn))
在管理商品后臺是,由于CheckBoxList的選擇太多,用戶需要一個全選或全取消的功能,這樣操作起來會提高效率同時可以減少誤點等,本文將教大家如何實現(xiàn),有需要的朋友可以參考下,望本文對你有所幫助2013-01-01gridview checkbox從服務器端和客戶端兩個方面實現(xiàn)全選和反選
GridView中的checkbox的全選和反選在很多的地方都是要求實現(xiàn)的,所以下面就從服務器端和客戶端兩個方面實現(xiàn)了checkbox的選擇,感興趣的朋友可以了解下,希望本文對你有所幫助2013-01-01